Zelda Classic Coverage Report


Directory: src/
File: src/guys.cpp
Date: 2022-12-28 06:29:58
Exec Total Coverage
Lines: 7476 12368 60.4%
Functions: 297 424 70.0%
Branches: 5767 14576 39.6%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // guys.cc
6 //
7 // "Guys" code (and other related stuff) for zelda.cc
8 //
9 //--------------------------------------------------------
10
11 #include "precompiled.h" //always first
12
13 #include <string.h>
14 #include <stdio.h>
15 #include "base/zc_alleg.h"
16
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 #include "guys.h"
17 #include "zelda.h"
18 #include "base/zsys.h"
19 #include "maps.h"
20 #include "hero.h"
21 #include "subscr.h"
22 #include "ffscript.h"
23 #include "gamedata.h"
24 #include "defdata.h"
25 #include "zscriptversion.h"
26 #include "particles.h"
27 #include "base/zc_math.h"
28 #include "slopes.h"
29 extern particle_list particles;
30
31 extern FFScript FFCore;
32 extern word item_doscript[256];
33 extern refInfo itemScriptData[256];
34 extern int32_t item_stack[256][MAX_SCRIPT_REGISTERS];
35 extern ZModule zcm;
36 extern HeroClass Hero;
37 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
38 extern zinitdata zinit;
39
40 int32_t repaircharge=0;
41 bool adjustmagic=false;
42 bool learnslash=false;
43 int32_t wallm_load_clk=0;
44 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
45 int32_t vhead=0;
46 int32_t guycarryingitem=0;
47
48 char *guy_string[eMAXGUYS];
49
50 void never_return(int32_t index);
51 void playLevelMusic();
52
53 // If an enemy is this far out of the playing field, just remove it.
54 #define OUTOFBOUNDS ((int32_t)y>((isSideViewGravity() && canfall(id))?192:352) || y<-176 || x<-256 || x > 512)
55 //#define NEWOUTOFBOUNDS ((int32_t)y>32767 || y<-32767 || x<-32767 || x > 32767)
56 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
57 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
58
59 333488 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
60 {
61 333488 int32_t c = coord.getInt();
62
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 333488 times.
333488 if(nearest_half)
63 {
64
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 333488 times.
333488 if (c < 0)
65 c -= val / 2;
66 333488 else c += (val/2);
67 333488 }
68 333488 c -= c % val;
69 333488 coord = c;
70 333488 }
71
72 bool NEWOUTOFBOUNDS(zfix x, zfix y, zfix z)
73 {
74 return
75 (
76 (((int32_t)y) > FFCore.enemy_removal_point[spriteremovalY2])
77 || (((int32_t)y) < FFCore.enemy_removal_point[spriteremovalY1])
78 || (((int32_t)x) < FFCore.enemy_removal_point[spriteremovalX1])
79 || (((int32_t)x) > FFCore.enemy_removal_point[spriteremovalX2])
80 || (((int32_t)z) < FFCore.enemy_removal_point[spriteremovalZ1])
81 || (((int32_t)z) > FFCore.enemy_removal_point[spriteremovalZ2])
82 );
83 }
84
85 namespace
86 {
87 int32_t trapConstantHorizontalID;
88 int32_t trapConstantVerticalID;
89 int32_t trapLOSHorizontalID;
90 int32_t trapLOSVerticalID;
91 int32_t trapLOS4WayID;
92
93 int32_t cornerTrapID;
94 int32_t centerTrapID;
95
96 int32_t rockID;
97 int32_t zoraID;
98 int32_t statueID;
99 }
100
101 74 void identifyCFEnemies()
102 {
103 74 trapConstantHorizontalID=-1;
104 74 trapConstantVerticalID=-1;
105 74 trapLOSHorizontalID=-1;
106 74 trapLOSVerticalID=-1;
107 74 trapLOS4WayID=-1;
108 74 cornerTrapID=-1;
109 74 centerTrapID=-1;
110 74 rockID=-1;
111 74 zoraID=-1;
112 74 statueID=-1;
113
114
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 74 times.
37962 for(int32_t i=0; i<eMAXGUYS; i++)
115 {
116
3/4
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 37814 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 74 times.
37888 if((guysbuf[i].flags2&cmbflag_trph) && trapLOSHorizontalID==-1)
117 74 trapLOSHorizontalID=i;
118
3/4
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 37814 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 74 times.
37888 if((guysbuf[i].flags2&cmbflag_trpv) && trapLOSVerticalID==-1)
119 74 trapLOSVerticalID=i;
120
3/4
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 37814 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 74 times.
37888 if((guysbuf[i].flags2&cmbflag_trp4) && trapLOS4WayID==-1)
121 74 trapLOS4WayID=i;
122
3/4
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 37814 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 74 times.
37888 if((guysbuf[i].flags2&cmbflag_trplr) && trapConstantHorizontalID==-1)
123 74 trapConstantHorizontalID=i;
124
3/4
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 37814 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 74 times.
37888 if((guysbuf[i].flags2&cmbflag_trpud) && trapConstantVerticalID==-1)
125 74 trapConstantVerticalID=i;
126
127
3/4
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 37814 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 74 times.
37888 if((guysbuf[i].flags2&eneflag_trap) && cornerTrapID==-1)
128 74 cornerTrapID=i;
129
3/4
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 37814 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 74 times.
37888 if((guysbuf[i].flags2&eneflag_trp2) && centerTrapID==-1)
130 74 centerTrapID=i;
131
132
3/4
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 37814 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 74 times.
37888 if((guysbuf[i].flags2&eneflag_rock) && rockID==-1)
133 74 rockID=i;
134
3/4
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 37814 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 74 times.
37888 if((guysbuf[i].flags2&eneflag_zora) && zoraID==-1)
135 74 zoraID=i;
136
137
4/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 37811 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 74 times.
37888 if((guysbuf[i].flags2 & eneflag_fire) && statueID==-1)
138 74 statueID=i;
139 37888 }
140 74 }
141
142 25 int32_t random_layer_enemy()
143 {
144 25 int32_t cnt=count_layer_enemies();
145
146
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(cnt==0)
147 {
148 return eNONE;
149 }
150
151 25 int32_t ret=zc_oldrand()%cnt;
152 25 cnt=0;
153
154
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 for(int32_t i=0; i<6; ++i)
155 {
156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(tmpscr->layermap[i]!=0)
157 {
158 25 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
159
160
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 for(int32_t j=0; j<10; ++j)
161 {
162
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
127 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
163 {
164
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 102 times.
127 if(cnt==ret)
165 {
166 25 return layerscreen->enemy[j];
167 }
168
169 102 ++cnt;
170 102 }
171 102 }
172 }
173 }
174
175 return eNONE;
176 25 }
177
178 39 int32_t count_layer_enemies()
179 {
180 39 int32_t cnt=0;
181
182
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 39 times.
273 for(int32_t i=0; i<6; ++i)
183 {
184
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 39 times.
234 if(tmpscr->layermap[i]!=0)
185 {
186 39 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
187
188
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 39 times.
429 for(int32_t j=0; j<10; ++j)
189 {
190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 390 times.
390 if(layerscreen->enemy[j]!=0)
191 {
192 390 ++cnt;
193 390 }
194 390 }
195 39 }
196 234 }
197
198 39 return cnt;
199 }
200
201 91422 int32_t hero_on_wall()
202 {
203 91422 zfix lx = Hero.getX();
204 91422 zfix ly = Hero.getY();
205
206
207 //zprint2("hero_on_wall x is: %d\n", lx);
208 //zprint2("hero_on_wall y is: %d\n", ly);
209
210
4/4
✓ Branch 0 taken 87250 times.
✓ Branch 1 taken 4172 times.
✓ Branch 2 taken 2378 times.
✓ Branch 3 taken 84872 times.
91422 if(lx>=48 && lx<=192)
211 {
212
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 84761 times.
84872 if(ly==32) return up+1;
213
214
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 84673 times.
84761 if(ly==128) return down+1;
215 84673 }
216
217
4/4
✓ Branch 0 taken 86653 times.
✓ Branch 1 taken 4570 times.
✓ Branch 2 taken 8838 times.
✓ Branch 3 taken 77815 times.
91223 if(ly>=48 && ly<=112)
218 {
219
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 77727 times.
77815 if(lx==32) return left+1;
220
221
2/2
✓ Branch 0 taken 77683 times.
✓ Branch 1 taken 44 times.
77727 if(lx==208) return right+1;
222 77683 }
223
224 91091 return 0;
225 91422 }
226
227 532633 bool tooclose(int32_t x,int32_t y,int32_t d)
228 {
229
2/2
✓ Branch 0 taken 392000 times.
✓ Branch 1 taken 140633 times.
532633 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
230 }
231
232 1145685 bool enemy::overpit(enemy *e)
233 {
234
2/2
✓ Branch 0 taken 1145418 times.
✓ Branch 1 taken 14277315 times.
15422733 for ( int32_t q = 0; q < hxsz; ++q )
235 {
236
2/2
✓ Branch 0 taken 131241703 times.
✓ Branch 1 taken 14277048 times.
145518751 for ( int32_t q = 0; q < hysz; ++q )
237 {
238 //check every pixel of the hitbox
239
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 131241436 times.
131241703 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
240 {
241 //if the hitbox is over a pit, we can't land
242 267 return true;
243 }
244 131241436 }
245 14277048 }
246 1145418 return false;
247 1145685 }
248
249 1603110 bool enemy::shadow_overpit(enemy *e)
250 {
251
2/2
✓ Branch 0 taken 1602753 times.
✓ Branch 1 taken 24252565 times.
25855318 for ( int32_t q = 0; q < hxsz; ++q )
252 {
253
2/2
✓ Branch 0 taken 354458433 times.
✓ Branch 1 taken 24252208 times.
378710641 for ( int32_t q = 0; q < hysz; ++q )
254 {
255 //check every pixel of the hitbox
256
2/2
✓ Branch 0 taken 357 times.
✓ Branch 1 taken 354458076 times.
354458433 if ( ispitfall(x+q+hxofs, y+q+hyofs+hysz-2) )
257 {
258 //if the hitbox is over a pit, we can't land
259 357 return true;
260 }
261 354458076 }
262 24252208 }
263 1602753 return false;
264 1603110 }
265
266 // Returns true iff a combo type or flag precludes enemy movement.
267 1745635 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
268 {
269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1745635 times.
1745635 if(moveflags & FLAG_IGNORE_BLOCKFLAGS) return false;
270 1745635 int32_t c = COMBOTYPE(dx,dy);
271
4/4
✓ Branch 0 taken 1121676 times.
✓ Branch 1 taken 623959 times.
✓ Branch 2 taken 50076 times.
✓ Branch 3 taken 573883 times.
2369594 bool pit_blocks = (!(moveflags & (FLAG_CAN_PITWALK|FLAG_ONLY_PITWALK)) && (!(moveflags & FLAG_CAN_PITFALL) || !isKB));
272
3/6
✓ Branch 0 taken 612687 times.
✓ Branch 1 taken 1132948 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 612687 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1745635 bool water_blocks = (!(moveflags & (FLAG_CAN_WATERWALK|FLAG_ONLY_WATERWALK|FLAG_ONLY_SHALLOW_WATERWALK)) && (!(moveflags & FLAG_CAN_WATERDROWN) || !isKB) && get_bit(quest_rules,qr_DROWN));
273
4/6
✓ Branch 0 taken 643324 times.
✓ Branch 1 taken 1102311 times.
✓ Branch 2 taken 643324 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 643324 times.
✗ Branch 5 not taken.
3491715 return c==cPIT || c==cPITB || c==cPITC ||
274
4/6
✓ Branch 0 taken 643324 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 643324 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 551378 times.
✓ Branch 5 taken 91946 times.
643324 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
275 // Block enemies type and block enemies flags
276
2/2
✓ Branch 0 taken 643324 times.
✓ Branch 1 taken 551378 times.
91946 combo_class_buf[c].block_enemies&1 ||
277
3/4
✓ Branch 0 taken 643322 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 643322 times.
✗ Branch 3 not taken.
643324 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
278
4/4
✓ Branch 0 taken 643308 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 643298 times.
✓ Branch 3 taken 10 times.
643322 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
279 // Check for ladder-only combos which aren't dried water
280
3/4
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 643224 times.
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
1286596 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
281 // Check for drownable water
282
4/4
✓ Branch 0 taken 26298 times.
✓ Branch 1 taken 617000 times.
✓ Branch 2 taken 12720 times.
✓ Branch 3 taken 13578 times.
643298 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true, false, false)));
283 643769 }
284
285 // Returns true iff enemy is floating and blocked by a combo type or flag.
286 2499478 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
287 {
288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2499478 times.
2499478 if(moveflags & FLAG_IGNORE_BLOCKFLAGS) return false;
289
4/4
✓ Branch 0 taken 2282280 times.
✓ Branch 1 taken 217198 times.
✓ Branch 2 taken 23478 times.
✓ Branch 3 taken 193720 times.
2716676 bool pit_blocks = (!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !isKB));
290
3/4
✓ Branch 0 taken 2290181 times.
✓ Branch 1 taken 209297 times.
✓ Branch 2 taken 209297 times.
✗ Branch 3 not taken.
2708775 bool water_blocks = (!(moveflags & FLAG_CAN_WATERWALK) && (!(moveflags & FLAG_CAN_WATERDROWN) || !isKB));
291
2/2
✓ Branch 0 taken 242990 times.
✓ Branch 1 taken 2256488 times.
4755966 return ((special==spw_floater)&&
292
2/2
✓ Branch 0 taken 2251742 times.
✓ Branch 1 taken 4746 times.
2256488 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
293
1/2
✓ Branch 0 taken 2251742 times.
✗ Branch 1 not taken.
2251742 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
294
1/2
✓ Branch 0 taken 2251742 times.
✗ Branch 1 not taken.
2251742 (MAPFLAG(dx,dy)==mfNOENEMY)||
295
1/2
✓ Branch 0 taken 2251742 times.
✗ Branch 1 not taken.
2251742 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
296
3/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 2251720 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22 times.
4503484 (water_blocks && iswaterex(MAPCOMBO(dx, dy), currmap, currscr, -1, dx,dy, false, false, true)) ||
297
2/2
✓ Branch 0 taken 2246682 times.
✓ Branch 1 taken 5060 times.
2251742 (pit_blocks && ispitfall(dx,dy))));
298 2499478 }
299 // Returns true iff a combo type or flag precludes enemy movement.
300 187360 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
301 {
302 187360 int32_t c = COMBOTYPE(dx,dy);
303 187360 bool pit_blocks = !(gd.moveflags & FLAG_CAN_PITWALK);
304
2/2
✓ Branch 0 taken 21821 times.
✓ Branch 1 taken 165539 times.
187360 bool water_blocks = !(gd.moveflags & FLAG_CAN_WATERWALK) && get_bit(quest_rules,qr_DROWN);
305
3/6
✓ Branch 0 taken 187360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 187360 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 187360 times.
✗ Branch 5 not taken.
711306 return c==cPIT || c==cPITB || c==cPITC ||
306
4/6
✓ Branch 0 taken 187360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 187360 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 168300 times.
✓ Branch 5 taken 19060 times.
187360 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
307 // Block enemies type and block enemies flags
308
2/2
✓ Branch 0 taken 187353 times.
✓ Branch 1 taken 168293 times.
19060 combo_class_buf[c].block_enemies&1 ||
309
3/4
✓ Branch 0 taken 187316 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 187316 times.
✗ Branch 3 not taken.
187353 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
310
3/4
✓ Branch 0 taken 184536 times.
✓ Branch 1 taken 2780 times.
✓ Branch 2 taken 184536 times.
✗ Branch 3 not taken.
187316 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
311 // Check for ladder-only combos which aren't dried water
312
3/4
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 184513 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
369072 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
313 // Check for drownable water
314
4/4
✓ Branch 0 taken 1544 times.
✓ Branch 1 taken 182992 times.
✓ Branch 2 taken 1134 times.
✓ Branch 3 taken 410 times.
184536 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)));
315 }
316
317 // Returns true iff enemy is floating and blocked by a combo type or flag.
318 72609 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
319 {
320
1/2
✓ Branch 0 taken 72609 times.
✗ Branch 1 not taken.
72609 bool pit_blocks = (!(gd.moveflags & FLAG_CAN_PITWALK) && !(gd.moveflags & FLAG_CAN_PITFALL));
321 72609 bool water_blocks = !(gd.moveflags & FLAG_CAN_WATERWALK);
322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72609 times.
145218 return ((special==spw_floater)&&
323
1/2
✓ Branch 0 taken 72609 times.
✗ Branch 1 not taken.
72609 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
324
1/2
✓ Branch 0 taken 72609 times.
✗ Branch 1 not taken.
72609 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
325
1/2
✓ Branch 0 taken 72609 times.
✗ Branch 1 not taken.
72609 (MAPFLAG(dx,dy)==mfNOENEMY)||
326
1/2
✓ Branch 0 taken 72609 times.
✗ Branch 1 not taken.
72609 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
327
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72609 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
145218 (water_blocks && iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)) ||
328
1/2
✓ Branch 0 taken 72609 times.
✗ Branch 1 not taken.
72609 (pit_blocks && ispitfall(dx,dy))));
329 }
330
331 /**********************************/
332 /******* Enemy Base Class *******/
333 /**********************************/
334
335 /* ROM data flags
336
337 */
338
339 eFire::eFire(eFire const & other, bool new_script_uid, bool clear_parent_script_UID):
340 //Struct Element Type Purpose
341 //sprite(other),
342 enemy(other),
343 clk4(other.clk4),
344 shield(other.shield)
345
346 {
347
348 //arrays
349
350 if(other.scrmem)
351 {
352 alloc_scriptmem();
353 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
354
355 scrmem->scriptData = other.scrmem->scriptData;
356 }
357 else scrmem = NULL;
358 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
359 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
360
361 for(int32_t i=0; i<edefLAST255; i++)
362 defense[i]=other.defense[i];
363 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
364 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
365
366 if(new_script_uid)
367 {
368 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
369 }
370 if(clear_parent_script_UID)
371 {
372 parent_script_UID = 0;
373 }
374 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
375 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
376
377 for ( int32_t q = 0; q < 8; q++ )
378 {
379 initD[q] = other.initD[q];
380 weap_initiald[q] = other.weap_initiald[q];
381 }
382 for ( int32_t q = 0; q < 2; q++ )
383 {
384 initA[q] = other.initA[q];
385 weap_initiala[q] = other.weap_initiala[q];
386 }
387 }
388
389 eOther::eOther(eOther const & other, bool new_script_uid, bool clear_parent_script_UID):
390 //Struct Element Type Purpose
391 //sprite(other),
392 enemy(other),
393 clk4(other.clk4),
394 shield(other.shield)
395
396 {
397
398 //arrays
399
400 if(other.scrmem)
401 {
402 alloc_scriptmem();
403 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
404
405 scrmem->scriptData = other.scrmem->scriptData;
406 }
407 else scrmem = NULL;
408 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
409 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
410
411 for(int32_t i=0; i<edefLAST255; i++)
412 defense[i]=other.defense[i];
413 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
414 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
415
416 if(new_script_uid)
417 {
418 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
419 }
420 if(clear_parent_script_UID)
421 {
422 parent_script_UID = 0;
423 }
424 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
425 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
426
427 for ( int32_t q = 0; q < 8; q++ )
428 {
429 initD[q] = other.initD[q];
430 weap_initiald[q] = other.weap_initiald[q];
431 }
432 for ( int32_t q = 0; q < 2; q++ )
433 {
434 initA[q] = other.initA[q];
435 weap_initiala[q] = other.weap_initiala[q];
436 }
437 }
438
439
440
441
442 eScript::eScript(eScript const & other, bool new_script_uid, bool clear_parent_script_UID):
443 //Struct Element Type Purpose
444 //sprite(other),
445 enemy(other),
446 clk4(other.clk4),
447 shield(other.shield)
448
449 {
450
451 //arrays
452
453 if(other.scrmem)
454 {
455 alloc_scriptmem();
456 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
457
458 scrmem->scriptData = other.scrmem->scriptData;
459 }
460 else scrmem = NULL;
461 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
462 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
463
464 for(int32_t i=0; i<edefLAST255; i++)
465 defense[i]=other.defense[i];
466 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
467 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
468
469 if(new_script_uid)
470 {
471 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
472 }
473 if(clear_parent_script_UID)
474 {
475 parent_script_UID = 0;
476 }
477 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
478 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
479
480 for ( int32_t q = 0; q < 8; q++ )
481 {
482 initD[q] = other.initD[q];
483 weap_initiald[q] = other.weap_initiald[q];
484 }
485 for ( int32_t q = 0; q < 2; q++ )
486 {
487 initA[q] = other.initA[q];
488 weap_initiala[q] = other.weap_initiala[q];
489 }
490 }
491
492 eFriendly::eFriendly(eFriendly const & other, bool new_script_uid, bool clear_parent_script_UID):
493 //Struct Element Type Purpose
494 //sprite(other),
495 enemy(other),
496 clk4(other.clk4),
497 shield(other.shield)
498
499 {
500
501 //arrays
502
503 if(other.scrmem)
504 {
505 alloc_scriptmem();
506 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
507
508 scrmem->scriptData = other.scrmem->scriptData;
509 }
510 else scrmem = NULL;
511 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
512 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
513
514 for(int32_t i=0; i<edefLAST255; i++)
515 defense[i]=other.defense[i];
516 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
517 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
518
519 if(new_script_uid)
520 {
521 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
522 }
523 if(clear_parent_script_UID)
524 {
525 parent_script_UID = 0;
526 }
527 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
528 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
529
530 for ( int32_t q = 0; q < 8; q++ )
531 {
532 initD[q] = other.initD[q];
533 weap_initiald[q] = other.weap_initiald[q];
534 }
535 for ( int32_t q = 0; q < 2; q++ )
536 {
537 initA[q] = other.initA[q];
538 weap_initiala[q] = other.weap_initiala[q];
539 }
540 }
541
542 eGhini::eGhini(eGhini const & other, bool new_script_uid, bool clear_parent_script_UID):
543 //Struct Element Type Purpose
544 //sprite(other),
545 enemy(other),
546 clk4(other.clk4),
547 ox(other.ox),
548 oy(other.oy),
549 c(other.c)
550
551 {
552
553 //arrays
554
555 if(other.scrmem)
556 {
557 alloc_scriptmem();
558 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
559
560 scrmem->scriptData = other.scrmem->scriptData;
561 }
562 else scrmem = NULL;
563 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
564 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
565
566 for(int32_t i=0; i<edefLAST255; i++)
567 defense[i]=other.defense[i];
568 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
569 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
570
571 if(new_script_uid)
572 {
573 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
574 }
575 if(clear_parent_script_UID)
576 {
577 parent_script_UID = 0;
578 }
579 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
580 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
581
582 for ( int32_t q = 0; q < 8; q++ )
583 {
584 initD[q] = other.initD[q];
585 weap_initiald[q] = other.weap_initiald[q];
586 }
587 for ( int32_t q = 0; q < 2; q++ )
588 {
589 initA[q] = other.initA[q];
590 weap_initiala[q] = other.weap_initiala[q];
591 }
592 }
593
594 eTektite::eTektite(eTektite const & other, bool new_script_uid, bool clear_parent_script_UID):
595 //Struct Element Type Purpose
596 //sprite(other),
597 enemy(other),
598 old_y(other.old_y),
599 clk2start(other.clk2start),
600 cstart(other.cstart),
601 c(other.c)
602
603 {
604
605 //arrays
606
607 if(other.scrmem)
608 {
609 alloc_scriptmem();
610 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
611
612 scrmem->scriptData = other.scrmem->scriptData;
613 }
614 else scrmem = NULL;
615 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
616 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
617
618 for(int32_t i=0; i<edefLAST255; i++)
619 defense[i]=other.defense[i];
620 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
621 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
622
623 if(new_script_uid)
624 {
625 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
626 }
627 if(clear_parent_script_UID)
628 {
629 parent_script_UID = 0;
630 }
631 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
632 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
633
634 for ( int32_t q = 0; q < 8; q++ )
635 {
636 initD[q] = other.initD[q];
637 weap_initiald[q] = other.weap_initiald[q];
638 }
639 for ( int32_t q = 0; q < 2; q++ )
640 {
641 initA[q] = other.initA[q];
642 weap_initiala[q] = other.weap_initiala[q];
643 }
644 }
645
646 eItemFairy::eItemFairy(eItemFairy const & other, bool new_script_uid, bool clear_parent_script_UID):
647 //Struct Element Type Purpose
648 //sprite(other),
649 enemy(other)
650 {
651
652 //arrays
653
654 if(other.scrmem)
655 {
656 alloc_scriptmem();
657 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
658
659 scrmem->scriptData = other.scrmem->scriptData;
660 }
661 else scrmem = NULL;
662 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
663 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
664
665 for(int32_t i=0; i<edefLAST255; i++)
666 defense[i]=other.defense[i];
667 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
668 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
669
670 if(new_script_uid)
671 {
672 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
673 }
674 if(clear_parent_script_UID)
675 {
676 parent_script_UID = 0;
677 }
678 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
679 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
680
681 for ( int32_t q = 0; q < 8; q++ )
682 {
683 initD[q] = other.initD[q];
684 weap_initiald[q] = other.weap_initiald[q];
685 }
686 for ( int32_t q = 0; q < 2; q++ )
687 {
688 initA[q] = other.initA[q];
689 weap_initiala[q] = other.weap_initiala[q];
690 }
691 }
692
693 ePeahat::ePeahat(ePeahat const & other, bool new_script_uid, bool clear_parent_script_UID):
694 //Struct Element Type Purpose
695 //sprite(other),
696 enemy(other),
697 ox(other.ox),
698 oy(other.oy),
699 c(other.c)
700 {
701
702 //arrays
703
704 if(other.scrmem)
705 {
706 alloc_scriptmem();
707 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
708
709 scrmem->scriptData = other.scrmem->scriptData;
710 }
711 else scrmem = NULL;
712 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
713 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
714
715 for(int32_t i=0; i<edefLAST255; i++)
716 defense[i]=other.defense[i];
717 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
718 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
719
720 if(new_script_uid)
721 {
722 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
723 }
724 if(clear_parent_script_UID)
725 {
726 parent_script_UID = 0;
727 }
728 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
729 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
730
731 for ( int32_t q = 0; q < 8; q++ )
732 {
733 initD[q] = other.initD[q];
734 weap_initiald[q] = other.weap_initiald[q];
735 }
736 for ( int32_t q = 0; q < 2; q++ )
737 {
738 initA[q] = other.initA[q];
739 weap_initiala[q] = other.weap_initiala[q];
740 }
741 }
742
743 eLeever::eLeever(eLeever const & other, bool new_script_uid, bool clear_parent_script_UID):
744 //Struct Element Type Purpose
745 //sprite(other),
746 enemy(other),
747 temprule(other.temprule)
748 {
749
750 //arrays
751
752 if(other.scrmem)
753 {
754 alloc_scriptmem();
755 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
756
757 scrmem->scriptData = other.scrmem->scriptData;
758 }
759 else scrmem = NULL;
760 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
761 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
762
763 for(int32_t i=0; i<edefLAST255; i++)
764 defense[i]=other.defense[i];
765 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
766 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
767
768 if(new_script_uid)
769 {
770 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
771 }
772 if(clear_parent_script_UID)
773 {
774 parent_script_UID = 0;
775 }
776 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
777 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
778
779 for ( int32_t q = 0; q < 8; q++ )
780 {
781 initD[q] = other.initD[q];
782 weap_initiald[q] = other.weap_initiald[q];
783 }
784 for ( int32_t q = 0; q < 2; q++ )
785 {
786 initA[q] = other.initA[q];
787 weap_initiala[q] = other.weap_initiala[q];
788 }
789 }
790
791 eWallM::eWallM(eWallM const & other, bool new_script_uid, bool clear_parent_script_UID):
792 //Struct Element Type Purpose
793 //sprite(other),
794 enemy(other)
795 {
796
797 //arrays
798
799 if(other.scrmem)
800 {
801 alloc_scriptmem();
802 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
803
804 scrmem->scriptData = other.scrmem->scriptData;
805 }
806 else scrmem = NULL;
807 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
808 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
809
810 for(int32_t i=0; i<edefLAST255; i++)
811 defense[i]=other.defense[i];
812 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
813 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
814
815 if(new_script_uid)
816 {
817 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
818 }
819 if(clear_parent_script_UID)
820 {
821 parent_script_UID = 0;
822 }
823 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
824 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
825
826 for ( int32_t q = 0; q < 8; q++ )
827 {
828 initD[q] = other.initD[q];
829 weap_initiald[q] = other.weap_initiald[q];
830 }
831 for ( int32_t q = 0; q < 2; q++ )
832 {
833 initA[q] = other.initA[q];
834 weap_initiala[q] = other.weap_initiala[q];
835 }
836 }
837
838 eStalfos::eStalfos(eStalfos const & other, bool new_script_uid, bool clear_parent_script_UID):
839 //Struct Element Type Purpose
840 //sprite(other),
841 enemy(other),
842 clk4(other.clk4),
843 clk5(other.clk5),
844 fired(other.fired),
845 shield(other.shield),
846 dashing(other.dashing),
847 multishot(other.multishot),
848 fy(other.fy),
849 shadowdistance(other.shadowdistance)
850 {
851
852 //arrays
853
854 if(other.scrmem)
855 {
856 alloc_scriptmem();
857 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
858
859 scrmem->scriptData = other.scrmem->scriptData;
860 }
861 else scrmem = NULL;
862 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
863 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
864
865 for(int32_t i=0; i<edefLAST255; i++)
866 defense[i]=other.defense[i];
867 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
868 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
869
870 if(new_script_uid)
871 {
872 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
873 }
874 if(clear_parent_script_UID)
875 {
876 parent_script_UID = 0;
877 }
878 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
879 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
880
881 for ( int32_t q = 0; q < 8; q++ )
882 {
883 initD[q] = other.initD[q];
884 weap_initiald[q] = other.weap_initiald[q];
885 }
886 for ( int32_t q = 0; q < 2; q++ )
887 {
888 initA[q] = other.initA[q];
889 weap_initiala[q] = other.weap_initiala[q];
890 }
891 }
892
893 eZora::eZora(eZora const & other, bool new_script_uid, bool clear_parent_script_UID):
894 //Struct Element Type Purpose
895 //sprite(other),
896 enemy(other)
897 {
898
899 //arrays
900
901 if(other.scrmem)
902 {
903 alloc_scriptmem();
904 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
905
906 scrmem->scriptData = other.scrmem->scriptData;
907 }
908 else scrmem = NULL;
909 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
910 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
911
912 for(int32_t i=0; i<edefLAST255; i++)
913 defense[i]=other.defense[i];
914 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
915 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
916
917 if(new_script_uid)
918 {
919 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
920 }
921 if(clear_parent_script_UID)
922 {
923 parent_script_UID = 0;
924 }
925 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
926 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
927
928 for ( int32_t q = 0; q < 8; q++ )
929 {
930 initD[q] = other.initD[q];
931 weap_initiald[q] = other.weap_initiald[q];
932 }
933 for ( int32_t q = 0; q < 2; q++ )
934 {
935 initA[q] = other.initA[q];
936 weap_initiala[q] = other.weap_initiala[q];
937 }
938 }
939
940 eSpinTile::eSpinTile(eSpinTile const & other, bool new_script_uid, bool clear_parent_script_UID):
941 //Struct Element Type Purpose
942 //sprite(other),
943 enemy(other)
944 {
945
946 //arrays
947
948 if(other.scrmem)
949 {
950 alloc_scriptmem();
951 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
952
953 scrmem->scriptData = other.scrmem->scriptData;
954 }
955 else scrmem = NULL;
956 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
957 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
958
959 for(int32_t i=0; i<edefLAST255; i++)
960 defense[i]=other.defense[i];
961 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
962 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
963
964 if(new_script_uid)
965 {
966 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
967 }
968 if(clear_parent_script_UID)
969 {
970 parent_script_UID = 0;
971 }
972 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
973 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
974
975 for ( int32_t q = 0; q < 8; q++ )
976 {
977 initD[q] = other.initD[q];
978 weap_initiald[q] = other.weap_initiald[q];
979 }
980 for ( int32_t q = 0; q < 2; q++ )
981 {
982 initA[q] = other.initA[q];
983 weap_initiala[q] = other.weap_initiala[q];
984 }
985 }
986
987 eNPC::eNPC(eNPC const & other, bool new_script_uid, bool clear_parent_script_UID):
988 //Struct Element Type Purpose
989 //sprite(other),
990 enemy(other)
991 {
992
993 //arrays
994
995 if(other.scrmem)
996 {
997 alloc_scriptmem();
998 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
999
1000 scrmem->scriptData = other.scrmem->scriptData;
1001 }
1002 else scrmem = NULL;
1003 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1004 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1005
1006 for(int32_t i=0; i<edefLAST255; i++)
1007 defense[i]=other.defense[i];
1008 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1009 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1010
1011 if(new_script_uid)
1012 {
1013 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1014 }
1015 if(clear_parent_script_UID)
1016 {
1017 parent_script_UID = 0;
1018 }
1019 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1020 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1021
1022 for ( int32_t q = 0; q < 8; q++ )
1023 {
1024 initD[q] = other.initD[q];
1025 weap_initiald[q] = other.weap_initiald[q];
1026 }
1027 for ( int32_t q = 0; q < 2; q++ )
1028 {
1029 initA[q] = other.initA[q];
1030 weap_initiala[q] = other.weap_initiala[q];
1031 }
1032 }
1033
1034 eTrigger::eTrigger(eTrigger const & other, bool new_script_uid, bool clear_parent_script_UID):
1035 //Struct Element Type Purpose
1036 //sprite(other),
1037 enemy(other)
1038 {
1039
1040 //arrays
1041
1042 if(other.scrmem)
1043 {
1044 alloc_scriptmem();
1045 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1046
1047 scrmem->scriptData = other.scrmem->scriptData;
1048 }
1049 else scrmem = NULL;
1050 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1051 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1052
1053 for(int32_t i=0; i<edefLAST255; i++)
1054 defense[i]=other.defense[i];
1055 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1056 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1057
1058 if(new_script_uid)
1059 {
1060 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1061 }
1062 if(clear_parent_script_UID)
1063 {
1064 parent_script_UID = 0;
1065 }
1066 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1067 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1068
1069 for ( int32_t q = 0; q < 8; q++ )
1070 {
1071 initD[q] = other.initD[q];
1072 weap_initiald[q] = other.weap_initiald[q];
1073 }
1074 for ( int32_t q = 0; q < 2; q++ )
1075 {
1076 initA[q] = other.initA[q];
1077 weap_initiala[q] = other.weap_initiala[q];
1078 }
1079 }
1080
1081 eProjectile::eProjectile(eProjectile const & other, bool new_script_uid, bool clear_parent_script_UID):
1082 //Struct Element Type Purpose
1083 //sprite(other),
1084 enemy(other),
1085 minRange(other.minRange)
1086 {
1087
1088 //arrays
1089
1090 if(other.scrmem)
1091 {
1092 alloc_scriptmem();
1093 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1094
1095 scrmem->scriptData = other.scrmem->scriptData;
1096 }
1097 else scrmem = NULL;
1098 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1099 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1100
1101 for(int32_t i=0; i<edefLAST255; i++)
1102 defense[i]=other.defense[i];
1103 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1104 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1105
1106 if(new_script_uid)
1107 {
1108 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1109 }
1110 if(clear_parent_script_UID)
1111 {
1112 parent_script_UID = 0;
1113 }
1114 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1115 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1116
1117 for ( int32_t q = 0; q < 8; q++ )
1118 {
1119 initD[q] = other.initD[q];
1120 weap_initiald[q] = other.weap_initiald[q];
1121 }
1122 for ( int32_t q = 0; q < 2; q++ )
1123 {
1124 initA[q] = other.initA[q];
1125 weap_initiala[q] = other.weap_initiala[q];
1126 }
1127 }
1128
1129 eBoulder::eBoulder(eBoulder const & other, bool new_script_uid, bool clear_parent_script_UID):
1130 //Struct Element Type Purpose
1131 //sprite(other),
1132 enemy(other)
1133 {
1134
1135 //arrays
1136
1137 if(other.scrmem)
1138 {
1139 alloc_scriptmem();
1140 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1141
1142 scrmem->scriptData = other.scrmem->scriptData;
1143 }
1144 else scrmem = NULL;
1145 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1146 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1147
1148 for(int32_t i=0; i<edefLAST255; i++)
1149 defense[i]=other.defense[i];
1150 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1151 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1152
1153 if(new_script_uid)
1154 {
1155 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1156 }
1157 if(clear_parent_script_UID)
1158 {
1159 parent_script_UID = 0;
1160 }
1161 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1162 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1163
1164 for ( int32_t q = 0; q < 8; q++ )
1165 {
1166 initD[q] = other.initD[q];
1167 weap_initiald[q] = other.weap_initiald[q];
1168 }
1169 for ( int32_t q = 0; q < 2; q++ )
1170 {
1171 initA[q] = other.initA[q];
1172 weap_initiala[q] = other.weap_initiala[q];
1173 }
1174 }
1175
1176 eRock::eRock(eRock const & other, bool new_script_uid, bool clear_parent_script_UID):
1177 //Struct Element Type Purpose
1178 //sprite(other),
1179 enemy(other)
1180 {
1181
1182 //arrays
1183
1184 if(other.scrmem)
1185 {
1186 alloc_scriptmem();
1187 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1188
1189 scrmem->scriptData = other.scrmem->scriptData;
1190 }
1191 else scrmem = NULL;
1192 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1193 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1194
1195 for(int32_t i=0; i<edefLAST255; i++)
1196 defense[i]=other.defense[i];
1197 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1198 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1199
1200 if(new_script_uid)
1201 {
1202 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1203 }
1204 if(clear_parent_script_UID)
1205 {
1206 parent_script_UID = 0;
1207 }
1208 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1209 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1210
1211 for ( int32_t q = 0; q < 8; q++ )
1212 {
1213 initD[q] = other.initD[q];
1214 weap_initiald[q] = other.weap_initiald[q];
1215 }
1216 for ( int32_t q = 0; q < 2; q++ )
1217 {
1218 initA[q] = other.initA[q];
1219 weap_initiala[q] = other.weap_initiala[q];
1220 }
1221 }
1222
1223 eTrap2::eTrap2(eTrap2 const & other, bool new_script_uid, bool clear_parent_script_UID):
1224 //Struct Element Type Purpose
1225 //sprite(other),
1226 enemy(other)
1227 {
1228
1229 //arrays
1230
1231 if(other.scrmem)
1232 {
1233 alloc_scriptmem();
1234 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1235
1236 scrmem->scriptData = other.scrmem->scriptData;
1237 }
1238 else scrmem = NULL;
1239 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1240 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1241
1242 for(int32_t i=0; i<edefLAST255; i++)
1243 defense[i]=other.defense[i];
1244 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1245 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1246
1247 if(new_script_uid)
1248 {
1249 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1250 }
1251 if(clear_parent_script_UID)
1252 {
1253 parent_script_UID = 0;
1254 }
1255 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1256 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1257
1258 for ( int32_t q = 0; q < 8; q++ )
1259 {
1260 initD[q] = other.initD[q];
1261 weap_initiald[q] = other.weap_initiald[q];
1262 }
1263 for ( int32_t q = 0; q < 2; q++ )
1264 {
1265 initA[q] = other.initA[q];
1266 weap_initiala[q] = other.weap_initiala[q];
1267 }
1268 }
1269
1270 eTrap::eTrap(eTrap const & other, bool new_script_uid, bool clear_parent_script_UID):
1271 //Struct Element Type Purpose
1272 //sprite(other),
1273 enemy(other),
1274 ox(other.ox),
1275 oy(other.oy)
1276 {
1277
1278 //arrays
1279
1280 if(other.scrmem)
1281 {
1282 alloc_scriptmem();
1283 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1284
1285 scrmem->scriptData = other.scrmem->scriptData;
1286 }
1287 else scrmem = NULL;
1288 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1289 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1290
1291 for(int32_t i=0; i<edefLAST255; i++)
1292 defense[i]=other.defense[i];
1293 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1294 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1295
1296 if(new_script_uid)
1297 {
1298 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1299 }
1300 if(clear_parent_script_UID)
1301 {
1302 parent_script_UID = 0;
1303 }
1304 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1305 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1306
1307 for ( int32_t q = 0; q < 8; q++ )
1308 {
1309 initD[q] = other.initD[q];
1310 weap_initiald[q] = other.weap_initiald[q];
1311 }
1312 for ( int32_t q = 0; q < 2; q++ )
1313 {
1314 initA[q] = other.initA[q];
1315 weap_initiala[q] = other.weap_initiala[q];
1316 }
1317 }
1318
1319
1320
1321
1322 eKeese::eKeese(eKeese const & other, bool new_script_uid, bool clear_parent_script_UID):
1323 //Struct Element Type Purpose
1324 //sprite(other),
1325 enemy(other),
1326 ox(other.ox),
1327 c(other.c),
1328 clk4(other.clk4),
1329 oy(other.oy)
1330 {
1331
1332 //arrays
1333
1334 if(other.scrmem)
1335 {
1336 alloc_scriptmem();
1337 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1338
1339 scrmem->scriptData = other.scrmem->scriptData;
1340 }
1341 else scrmem = NULL;
1342 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1343 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1344
1345 for(int32_t i=0; i<edefLAST255; i++)
1346 defense[i]=other.defense[i];
1347 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1348 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1349
1350 if(new_script_uid)
1351 {
1352 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1353 }
1354 if(clear_parent_script_UID)
1355 {
1356 parent_script_UID = 0;
1357 }
1358 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1359 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1360
1361 for ( int32_t q = 0; q < 8; q++ )
1362 {
1363 initD[q] = other.initD[q];
1364 weap_initiald[q] = other.weap_initiald[q];
1365 }
1366 for ( int32_t q = 0; q < 2; q++ )
1367 {
1368 initA[q] = other.initA[q];
1369 weap_initiala[q] = other.weap_initiala[q];
1370 }
1371 }
1372
1373 eWizzrobe::eWizzrobe(eWizzrobe const & other, bool new_script_uid, bool clear_parent_script_UID):
1374 //Struct Element Type Purpose
1375 //sprite(other),
1376 enemy(other),
1377 charging(other.charging),
1378 firing(other.firing),
1379 fclk(other.fclk)
1380 {
1381
1382 //arrays
1383
1384 if(other.scrmem)
1385 {
1386 alloc_scriptmem();
1387 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1388
1389 scrmem->scriptData = other.scrmem->scriptData;
1390 }
1391 else scrmem = NULL;
1392 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1393 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1394
1395 for(int32_t i=0; i<edefLAST255; i++)
1396 defense[i]=other.defense[i];
1397 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1398 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1399
1400 if(new_script_uid)
1401 {
1402 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1403 }
1404 if(clear_parent_script_UID)
1405 {
1406 parent_script_UID = 0;
1407 }
1408 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1409 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1410
1411 for ( int32_t q = 0; q < 8; q++ )
1412 {
1413 initD[q] = other.initD[q];
1414 weap_initiald[q] = other.weap_initiald[q];
1415 }
1416 for ( int32_t q = 0; q < 2; q++ )
1417 {
1418 initA[q] = other.initA[q];
1419 weap_initiala[q] = other.weap_initiala[q];
1420 }
1421 }
1422
1423 eDodongo::eDodongo(eDodongo const & other, bool new_script_uid, bool clear_parent_script_UID):
1424 //Struct Element Type Purpose
1425 //sprite(other),
1426 enemy(other)
1427 {
1428
1429 //arrays
1430
1431 if(other.scrmem)
1432 {
1433 alloc_scriptmem();
1434 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1435
1436 scrmem->scriptData = other.scrmem->scriptData;
1437 }
1438 else scrmem = NULL;
1439 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1440 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1441
1442 for(int32_t i=0; i<edefLAST255; i++)
1443 defense[i]=other.defense[i];
1444 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1445 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1446
1447 if(new_script_uid)
1448 {
1449 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1450 }
1451 if(clear_parent_script_UID)
1452 {
1453 parent_script_UID = 0;
1454 }
1455 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1456 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1457
1458 for ( int32_t q = 0; q < 8; q++ )
1459 {
1460 initD[q] = other.initD[q];
1461 weap_initiald[q] = other.weap_initiald[q];
1462 }
1463 for ( int32_t q = 0; q < 2; q++ )
1464 {
1465 initA[q] = other.initA[q];
1466 weap_initiala[q] = other.weap_initiala[q];
1467 }
1468 }
1469
1470 eDodongo2::eDodongo2(eDodongo2 const & other, bool new_script_uid, bool clear_parent_script_UID):
1471 //Struct Element Type Purpose
1472 //sprite(other),
1473 enemy(other),
1474 previous_dir(other.previous_dir)
1475 {
1476
1477 //arrays
1478
1479 if(other.scrmem)
1480 {
1481 alloc_scriptmem();
1482 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1483
1484 scrmem->scriptData = other.scrmem->scriptData;
1485 }
1486 else scrmem = NULL;
1487 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1488 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1489
1490 for(int32_t i=0; i<edefLAST255; i++)
1491 defense[i]=other.defense[i];
1492 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1493 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1494
1495 if(new_script_uid)
1496 {
1497 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1498 }
1499 if(clear_parent_script_UID)
1500 {
1501 parent_script_UID = 0;
1502 }
1503 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1504 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1505
1506 for ( int32_t q = 0; q < 8; q++ )
1507 {
1508 initD[q] = other.initD[q];
1509 weap_initiald[q] = other.weap_initiald[q];
1510 }
1511 for ( int32_t q = 0; q < 2; q++ )
1512 {
1513 initA[q] = other.initA[q];
1514 weap_initiala[q] = other.weap_initiala[q];
1515 }
1516 }
1517
1518 eAquamentus::eAquamentus(eAquamentus const & other, bool new_script_uid, bool clear_parent_script_UID):
1519 //Struct Element Type Purpose
1520 //sprite(other),
1521 enemy(other),
1522 fbx(other.fbx),
1523 clk4(other.clk4)
1524 {
1525
1526 //arrays
1527
1528 if(other.scrmem)
1529 {
1530 alloc_scriptmem();
1531 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1532
1533 scrmem->scriptData = other.scrmem->scriptData;
1534 }
1535 else scrmem = NULL;
1536 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1537 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1538
1539 for(int32_t i=0; i<edefLAST255; i++)
1540 defense[i]=other.defense[i];
1541 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1542 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1543
1544 if(new_script_uid)
1545 {
1546 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1547 }
1548 if(clear_parent_script_UID)
1549 {
1550 parent_script_UID = 0;
1551 }
1552 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1553 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1554
1555 for ( int32_t q = 0; q < 8; q++ )
1556 {
1557 initD[q] = other.initD[q];
1558 weap_initiald[q] = other.weap_initiald[q];
1559 }
1560 for ( int32_t q = 0; q < 2; q++ )
1561 {
1562 initA[q] = other.initA[q];
1563 weap_initiala[q] = other.weap_initiala[q];
1564 }
1565 }
1566
1567 eGohma::eGohma(eGohma const & other, bool new_script_uid, bool clear_parent_script_UID):
1568 //Struct Element Type Purpose
1569 //sprite(other),
1570 enemy(other),
1571 clk4(other.clk4)
1572 {
1573
1574 //arrays
1575
1576 if(other.scrmem)
1577 {
1578 alloc_scriptmem();
1579 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1580
1581 scrmem->scriptData = other.scrmem->scriptData;
1582 }
1583 else scrmem = NULL;
1584 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1585 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1586
1587 for(int32_t i=0; i<edefLAST255; i++)
1588 defense[i]=other.defense[i];
1589 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1590 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1591
1592 if(new_script_uid)
1593 {
1594 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1595 }
1596 if(clear_parent_script_UID)
1597 {
1598 parent_script_UID = 0;
1599 }
1600 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1601 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1602
1603 for ( int32_t q = 0; q < 8; q++ )
1604 {
1605 initD[q] = other.initD[q];
1606 weap_initiald[q] = other.weap_initiald[q];
1607 }
1608 for ( int32_t q = 0; q < 2; q++ )
1609 {
1610 initA[q] = other.initA[q];
1611 weap_initiala[q] = other.weap_initiala[q];
1612 }
1613 }
1614
1615 eLilDig::eLilDig(eLilDig const & other, bool new_script_uid, bool clear_parent_script_UID):
1616 //Struct Element Type Purpose
1617 //sprite(other),
1618 enemy(other)
1619 {
1620
1621 //arrays
1622
1623 if(other.scrmem)
1624 {
1625 alloc_scriptmem();
1626 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1627
1628 scrmem->scriptData = other.scrmem->scriptData;
1629 }
1630 else scrmem = NULL;
1631 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1632 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1633
1634 for(int32_t i=0; i<edefLAST255; i++)
1635 defense[i]=other.defense[i];
1636 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1637 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1638
1639 if(new_script_uid)
1640 {
1641 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1642 }
1643 if(clear_parent_script_UID)
1644 {
1645 parent_script_UID = 0;
1646 }
1647 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1648 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1649
1650 for ( int32_t q = 0; q < 8; q++ )
1651 {
1652 initD[q] = other.initD[q];
1653 weap_initiald[q] = other.weap_initiald[q];
1654 }
1655 for ( int32_t q = 0; q < 2; q++ )
1656 {
1657 initA[q] = other.initA[q];
1658 weap_initiala[q] = other.weap_initiala[q];
1659 }
1660 }
1661
1662 eBigDig::eBigDig(eBigDig const & other, bool new_script_uid, bool clear_parent_script_UID):
1663 //Struct Element Type Purpose
1664 //sprite(other),
1665 enemy(other)
1666 {
1667
1668 //arrays
1669
1670 if(other.scrmem)
1671 {
1672 alloc_scriptmem();
1673 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1674
1675 scrmem->scriptData = other.scrmem->scriptData;
1676 }
1677 else scrmem = NULL;
1678 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1679 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1680
1681 for(int32_t i=0; i<edefLAST255; i++)
1682 defense[i]=other.defense[i];
1683 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1684 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1685
1686 if(new_script_uid)
1687 {
1688 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1689 }
1690 if(clear_parent_script_UID)
1691 {
1692 parent_script_UID = 0;
1693 }
1694 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1695 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1696
1697 for ( int32_t q = 0; q < 8; q++ )
1698 {
1699 initD[q] = other.initD[q];
1700 weap_initiald[q] = other.weap_initiald[q];
1701 }
1702 for ( int32_t q = 0; q < 2; q++ )
1703 {
1704 initA[q] = other.initA[q];
1705 weap_initiala[q] = other.weap_initiala[q];
1706 }
1707 }
1708
1709 eGanon::eGanon(eGanon const & other, bool new_script_uid, bool clear_parent_script_UID):
1710 //Struct Element Type Purpose
1711 //sprite(other),
1712 enemy(other),
1713 Stunclk(other.Stunclk)
1714
1715 {
1716
1717 //arrays
1718
1719 if(other.scrmem)
1720 {
1721 alloc_scriptmem();
1722 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1723
1724 scrmem->scriptData = other.scrmem->scriptData;
1725 }
1726 else scrmem = NULL;
1727 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1728 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1729
1730 for(int32_t i=0; i<edefLAST255; i++)
1731 defense[i]=other.defense[i];
1732 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1733 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1734
1735 if(new_script_uid)
1736 {
1737 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1738 }
1739 if(clear_parent_script_UID)
1740 {
1741 parent_script_UID = 0;
1742 }
1743 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1744 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1745
1746 for ( int32_t q = 0; q < 8; q++ )
1747 {
1748 initD[q] = other.initD[q];
1749 weap_initiald[q] = other.weap_initiald[q];
1750 }
1751 for ( int32_t q = 0; q < 2; q++ )
1752 {
1753 initA[q] = other.initA[q];
1754 weap_initiala[q] = other.weap_initiala[q];
1755 }
1756 }
1757
1758 eMoldorm::eMoldorm(eMoldorm const & other, bool new_script_uid, bool clear_parent_script_UID):
1759 //Struct Element Type Purpose
1760 //sprite(other),
1761 enemy(other),
1762 segcnt(other.segcnt),
1763 segid(other.segid)
1764
1765 {
1766
1767 //arrays
1768
1769 if(other.scrmem)
1770 {
1771 alloc_scriptmem();
1772 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1773
1774 scrmem->scriptData = other.scrmem->scriptData;
1775 }
1776 else scrmem = NULL;
1777 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1778 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1779
1780 for(int32_t i=0; i<edefLAST255; i++)
1781 defense[i]=other.defense[i];
1782 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1783 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1784
1785 if(new_script_uid)
1786 {
1787 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1788 }
1789 if(clear_parent_script_UID)
1790 {
1791 parent_script_UID = 0;
1792 }
1793 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1794 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1795
1796 for ( int32_t q = 0; q < 8; q++ )
1797 {
1798 initD[q] = other.initD[q];
1799 weap_initiald[q] = other.weap_initiald[q];
1800 }
1801 for ( int32_t q = 0; q < 2; q++ )
1802 {
1803 initA[q] = other.initA[q];
1804 weap_initiala[q] = other.weap_initiala[q];
1805 }
1806 }
1807
1808 esMoldorm::esMoldorm(esMoldorm const & other, bool new_script_uid, bool clear_parent_script_UID):
1809 //Struct Element Type Purpose
1810 //sprite(other),
1811 enemy(other),
1812 parentclk(other.parentclk)
1813 {
1814
1815 //arrays
1816
1817 if(other.scrmem)
1818 {
1819 alloc_scriptmem();
1820 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1821
1822 scrmem->scriptData = other.scrmem->scriptData;
1823 }
1824 else scrmem = NULL;
1825 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1826 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1827
1828 for(int32_t i=0; i<edefLAST255; i++)
1829 defense[i]=other.defense[i];
1830 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1831 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1832
1833 if(new_script_uid)
1834 {
1835 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1836 }
1837 if(clear_parent_script_UID)
1838 {
1839 parent_script_UID = 0;
1840 }
1841 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1842 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1843
1844 for ( int32_t q = 0; q < 8; q++ )
1845 {
1846 initD[q] = other.initD[q];
1847 weap_initiald[q] = other.weap_initiald[q];
1848 }
1849 for ( int32_t q = 0; q < 2; q++ )
1850 {
1851 initA[q] = other.initA[q];
1852 weap_initiala[q] = other.weap_initiala[q];
1853 }
1854 }
1855 /*
1856 eManhandla::eManhandla(eManhandla const & other, bool new_script_uid, bool clear_parent_script_UID):
1857 //Struct Element Type Purpose
1858 //sprite(other),
1859 enemy(other),
1860 armcnt(armcnt),
1861 adjusted(adjusted),
1862 arm[0](arm[0]),
1863 arm[1](arm[1]),
1864 arm[2](arm[2]),
1865 arm[3](arm[3]),
1866 arm[4](arm[4]),
1867 arm[5](arm[5]),
1868 arm[6](arm[6]),
1869 arm[7](arm[7])
1870 {
1871
1872 //arrays
1873 if(other.scrmem)
1874 {
1875 alloc_scriptmem();
1876 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1877
1878 scrmem->scriptData = other.scrmem->scriptData;
1879 }
1880 else scrmem = NULL;
1881 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1882 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1883
1884 for(int32_t i=0; i<edefLAST255; i++)
1885 defense[i]=other.defense[i];
1886 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1887 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1888
1889 if(new_script_uid)
1890 {
1891 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1892 }
1893 if(clear_parent_script_UID)
1894 {
1895 parent_script_UID = 0;
1896 }
1897 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1898 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1899
1900 for ( int32_t q = 0; q < 8; q++ )
1901 {
1902 initD[q] = other.initD[q];
1903 weap_initiald[q] = other.weap_initiald[q];
1904 }
1905 for ( int32_t q = 0; q < 2; q++ )
1906 {
1907 initA[q] = other.initA[q];
1908 weap_initiala[q] = other.weap_initiala[q];
1909 }
1910 }
1911
1912 esManhandla::esManhandla(esManhandla const & other, bool new_script_uid, bool clear_parent_script_UID):
1913 //Struct Element Type Purpose
1914 //sprite(other),
1915 enemy(other)
1916 {
1917
1918 //arrays
1919 if(other.scrmem)
1920 {
1921 alloc_scriptmem();
1922 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1923
1924 scrmem->scriptData = other.scrmem->scriptData;
1925 }
1926 else scrmem = NULL;
1927 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1928 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1929
1930 for(int32_t i=0; i<edefLAST255; i++)
1931 defense[i]=other.defense[i];
1932 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1933 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1934
1935 if(new_script_uid)
1936 {
1937 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1938 }
1939 if(clear_parent_script_UID)
1940 {
1941 parent_script_UID = 0;
1942 }
1943 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1944 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1945
1946 for ( int32_t q = 0; q < 8; q++ )
1947 {
1948 initD[q] = other.initD[q];
1949 weap_initiald[q] = other.weap_initiald[q];
1950 }
1951 for ( int32_t q = 0; q < 2; q++ )
1952 {
1953 initA[q] = other.initA[q];
1954 weap_initiala[q] = other.weap_initiala[q];
1955 }
1956 }
1957
1958 eGleeok::eGleeok(eGleeok const & other, bool new_script_uid, bool clear_parent_script_UID):
1959 //Struct Element Type Purpose
1960 //sprite(other),
1961 enemy(other),
1962 flameclk(flameclk),
1963 flamehead(flamehead),
1964 necktile(necktile)
1965
1966 {
1967
1968 //arrays
1969
1970 if(other.scrmem)
1971 {
1972 alloc_scriptmem();
1973 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1974
1975 scrmem->scriptData = other.scrmem->scriptData;
1976 }
1977 else scrmem = NULL;
1978 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1979 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1980
1981 for(int32_t i=0; i<edefLAST255; i++)
1982 defense[i]=other.defense[i];
1983 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1984 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1985
1986 if(new_script_uid)
1987 {
1988 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1989 }
1990 if(clear_parent_script_UID)
1991 {
1992 parent_script_UID = 0;
1993 }
1994 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1995 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1996
1997 for ( int32_t q = 0; q < 8; q++ )
1998 {
1999 initD[q] = other.initD[q];
2000 weap_initiald[q] = other.weap_initiald[q];
2001 }
2002 for ( int32_t q = 0; q < 2; q++ )
2003 {
2004 initA[q] = other.initA[q];
2005 weap_initiala[q] = other.weap_initiala[q];
2006 }
2007 }
2008
2009 esGleeok::esGleeok(esGleeok const & other, bool new_script_uid, bool clear_parent_script_UID):
2010 //Struct Element Type Purpose
2011 //sprite(other),
2012 enemy(other),
2013 headtile(headtile),
2014 flyingheadtile(flyingheadtile),
2015 necktile(necktile),
2016 xoffset(xoffset),
2017 yoffset(yoffset),
2018 nx(nx),
2019 ny(ny),
2020 nxoffset(nxoffset),
2021 nyoffset(nyoffset),
2022 parent(parent)
2023
2024 {
2025
2026 //arrays
2027
2028 if(other.scrmem)
2029 {
2030 alloc_scriptmem();
2031 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2032
2033 scrmem->scriptData = other.scrmem->scriptData;
2034 }
2035 else scrmem = NULL;
2036 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2037 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2038
2039 //for ( int32_t q = 0; q < 255; q++ )
2040 //{
2041 // nx[q] = other.nx[q];
2042 // ny[q] = other.ny[q];
2043 // nxoffset[q] = other.nxoffset[q];
2044 // nyoffset[q] = other.nyoffset[q];
2045 //}
2046
2047 for(int32_t i=0; i<edefLAST255; i++)
2048 defense[i]=other.defense[i];
2049 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2050 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2051
2052 if(new_script_uid)
2053 {
2054 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2055 }
2056 if(clear_parent_script_UID)
2057 {
2058 parent_script_UID = 0;
2059 }
2060 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2061 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2062
2063 for ( int32_t q = 0; q < 8; q++ )
2064 {
2065 initD[q] = other.initD[q];
2066 weap_initiald[q] = other.weap_initiald[q];
2067 }
2068 for ( int32_t q = 0; q < 2; q++ )
2069 {
2070 initA[q] = other.initA[q];
2071 weap_initiala[q] = other.weap_initiala[q];
2072 }
2073 }
2074
2075 ePatra::ePatra(ePatra const & other, bool new_script_uid, bool clear_parent_script_UID):
2076 //Struct Element Type Purpose
2077 //sprite(other),
2078 enemy(other),
2079 flycnt(flycnt),
2080 flycnt2(flycnt2),
2081 loopcnt(loopcnt),
2082 lookat(lookat),
2083 circle_x(circle_x),
2084 circle_y(circle_y),
2085 temp_x(temp_x),
2086 temp_y(temp_y),
2087 adjusted(adjusted)
2088
2089 {
2090
2091 //arrays
2092
2093 if(other.scrmem)
2094 {
2095 alloc_scriptmem();
2096 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2097
2098 scrmem->scriptData = other.scrmem->scriptData;
2099 }
2100 else scrmem = NULL;
2101 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2102 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2103
2104 for(int32_t i=0; i<edefLAST255; i++)
2105 defense[i]=other.defense[i];
2106 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2107 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2108
2109 if(new_script_uid)
2110 {
2111 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2112 }
2113 if(clear_parent_script_UID)
2114 {
2115 parent_script_UID = 0;
2116 }
2117 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2118 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2119
2120 for ( int32_t q = 0; q < 8; q++ )
2121 {
2122 initD[q] = other.initD[q];
2123 weap_initiald[q] = other.weap_initiald[q];
2124 }
2125 for ( int32_t q = 0; q < 2; q++ )
2126 {
2127 initA[q] = other.initA[q];
2128 weap_initiala[q] = other.weap_initiala[q];
2129 }
2130 }
2131
2132 ePatraBS::ePatraBS(ePatraBS const & other, bool new_script_uid, bool clear_parent_script_UID):
2133 //Struct Element Type Purpose
2134 //sprite(other),
2135 enemy(other),
2136 flycnt(flycnt),
2137 flycnt2(flycnt2),
2138 loopcnt(loopcnt),
2139 lookat(lookat),
2140 adjusted(adjusted)
2141
2142 {
2143
2144 //arrays
2145
2146 if(other.scrmem)
2147 {
2148 alloc_scriptmem();
2149 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2150
2151 scrmem->scriptData = other.scrmem->scriptData;
2152 }
2153 else scrmem = NULL;
2154 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2155 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2156
2157 for(int32_t i=0; i<edefLAST255; i++)
2158 defense[i]=other.defense[i];
2159 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2160 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2161
2162 if(new_script_uid)
2163 {
2164 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2165 }
2166 if(clear_parent_script_UID)
2167 {
2168 parent_script_UID = 0;
2169 }
2170 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2171 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2172
2173 for ( int32_t q = 0; q < 8; q++ )
2174 {
2175 initD[q] = other.initD[q];
2176 weap_initiald[q] = other.weap_initiald[q];
2177 }
2178 for ( int32_t q = 0; q < 2; q++ )
2179 {
2180 initA[q] = other.initA[q];
2181 weap_initiala[q] = other.weap_initiala[q];
2182 }
2183 }
2184
2185 esPatra::esPatra(esPatra const & other, bool new_script_uid, bool clear_parent_script_UID):
2186 //Struct Element Type Purpose
2187 //sprite(other),
2188 enemy(other)
2189
2190 {
2191
2192 //arrays
2193
2194 if(other.scrmem)
2195 {
2196 alloc_scriptmem();
2197 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2198
2199 scrmem->scriptData = other.scrmem->scriptData;
2200 }
2201 else scrmem = NULL;
2202 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2203 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2204
2205 for ( int32_t q = 0; q < 255; q++ )
2206 {
2207 nx[q] = other.nx[q];
2208 ny[q] = other.ny[q];
2209 nxoffset[q] = other.nxoffset[q];
2210 nyoffset[q] = other.nyoffset[q];
2211 }
2212
2213 for(int32_t i=0; i<edefLAST255; i++)
2214 defense[i]=other.defense[i];
2215 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2216 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2217
2218 if(new_script_uid)
2219 {
2220 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2221 }
2222 if(clear_parent_script_UID)
2223 {
2224 parent_script_UID = 0;
2225 }
2226 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2227 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2228
2229 for ( int32_t q = 0; q < 8; q++ )
2230 {
2231 initD[q] = other.initD[q];
2232 weap_initiald[q] = other.weap_initiald[q];
2233 }
2234 for ( int32_t q = 0; q < 2; q++ )
2235 {
2236 initA[q] = other.initA[q];
2237 weap_initiala[q] = other.weap_initiala[q];
2238 }
2239 }
2240
2241 esPatraBS::esPatraBS(esPatraBS const & other, bool new_script_uid, bool clear_parent_script_UID):
2242 //Struct Element Type Purpose
2243 //sprite(other),
2244 enemy(other)
2245
2246 {
2247
2248 //arrays
2249
2250 if(other.scrmem)
2251 {
2252 alloc_scriptmem();
2253 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2254
2255 scrmem->scriptData = other.scrmem->scriptData;
2256 }
2257 else scrmem = NULL;
2258 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2259 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2260
2261 for ( int32_t q = 0; q < 255; q++ )
2262 {
2263 nx[q] = other.nx[q];
2264 ny[q] = other.ny[q];
2265 nxoffset[q] = other.nxoffset[q];
2266 nyoffset[q] = other.nyoffset[q];
2267 }
2268
2269 for(int32_t i=0; i<edefLAST255; i++)
2270 defense[i]=other.defense[i];
2271 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2272 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2273
2274 if(new_script_uid)
2275 {
2276 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2277 }
2278 if(clear_parent_script_UID)
2279 {
2280 parent_script_UID = 0;
2281 }
2282 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2283 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2284
2285 for ( int32_t q = 0; q < 8; q++ )
2286 {
2287 initD[q] = other.initD[q];
2288 weap_initiald[q] = other.weap_initiald[q];
2289 }
2290 for ( int32_t q = 0; q < 2; q++ )
2291 {
2292 initA[q] = other.initA[q];
2293 weap_initiala[q] = other.weap_initiala[q];
2294 }
2295 }
2296
2297 */
2298
2299
5/10
✓ Branch 0 taken 23298 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23298 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23298 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23298 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 23298 times.
✗ Branch 9 not taken.
69894 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
2300 46596 {
2301
1/2
✓ Branch 0 taken 23298 times.
✗ Branch 1 not taken.
23298 x=X;
2302
1/2
✓ Branch 0 taken 23298 times.
✗ Branch 1 not taken.
23298 y=Y;
2303 23298 id=Id;
2304 23298 clk=Clk;
2305
1/2
✓ Branch 0 taken 23298 times.
✗ Branch 1 not taken.
23298 floor_y=y;
2306 23298 ceiling=false;
2307 23298 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
2308 23298 grumble = movestatus = posframe = timer = ox = oy = 0;
2309
4/8
✓ Branch 0 taken 23298 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23298 times.
✓ Branch 4 taken 23298 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23298 times.
✗ Branch 7 not taken.
23298 yofs = (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
2310 23298 did_armos=true;
2311 23298 script_spawned=false;
2312
2313 23298 d = guysbuf + (id & 0xFFF);
2314 23298 hp = d->hp;
2315 23298 starting_hp = hp;
2316 // cs = d->cset;
2317 //d variables
2318
2319 23298 flags=d->flags;
2320 23298 flags2=d->flags2;
2321 23298 s_tile=d->s_tile; //secondary (additional) tile(s)
2322 23298 family=d->family;
2323 23298 dcset=d->cset;
2324 23298 cs=dcset;
2325
3/4
✓ Branch 0 taken 23298 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13709 times.
✓ Branch 3 taken 9589 times.
23298 anim=get_bit(quest_rules,qr_NEWENEMYTILES)?d->e_anim:d->anim;
2326 23298 dp=d->dp;
2327 23298 wdp=d->wdp;
2328 23298 wpn=d->weapon;
2329 23298 wpnsprite = d-> wpnsprite; //2.6 -Z
2330 23298 rate=d->rate;
2331 23298 hrate=d->hrate;
2332
1/2
✓ Branch 0 taken 23298 times.
✗ Branch 1 not taken.
23298 dstep=d->step;
2333 23298 homing=d->homing;
2334 23298 dmisc1=d->misc1;
2335 23298 dmisc2=d->misc2;
2336 23298 dmisc3=d->misc3;
2337 23298 dmisc4=d->misc4;
2338 23298 dmisc5=d->misc5;
2339 23298 dmisc6=d->misc6;
2340 23298 dmisc7=d->misc7;
2341 23298 dmisc8=d->misc8;
2342 23298 dmisc9=d->misc9;
2343 23298 dmisc10=d->misc10;
2344 23298 dmisc11=d->misc11;
2345 23298 dmisc12=d->misc12;
2346 23298 dmisc13=d->misc13;
2347 23298 dmisc14=d->misc14;
2348 23298 dmisc15=d->misc15;
2349 23298 dmisc16=d->misc16;
2350 23298 dmisc17=d->misc17;
2351 23298 dmisc18=d->misc18;
2352 23298 dmisc19=d->misc19;
2353 23298 dmisc20=d->misc20;
2354 23298 dmisc21=d->misc21;
2355 23298 dmisc22=d->misc22;
2356 23298 dmisc23=d->misc23;
2357 23298 dmisc24=d->misc24;
2358 23298 dmisc25=d->misc25;
2359 23298 dmisc26=d->misc26;
2360 23298 dmisc27=d->misc27;
2361 23298 dmisc28=d->misc28;
2362 23298 dmisc29=d->misc29;
2363 23298 dmisc30=d->misc30;
2364 23298 dmisc31=d->misc31;
2365 23298 dmisc32=d->misc32;
2366
3/4
✓ Branch 0 taken 23298 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22830 times.
✓ Branch 3 taken 468 times.
23298 if (get_bit(quest_rules, qr_BROKEN_ATTRIBUTE_31_32))
2367 {
2368 22830 dmisc31 = dmisc32;
2369 22830 dmisc32 = 0;
2370 22830 }
2371 23298 spr_shadow=d->spr_shadow;
2372 23298 spr_death=d->spr_death;
2373 23298 spr_spawn=d->spr_spawn;
2374
2375
2/2
✓ Branch 0 taken 955218 times.
✓ Branch 1 taken 23298 times.
978516 for(int32_t i=0; i<edefLAST255; i++)
2376 955218 defense[i]=d->defense[i];
2377
2378 23298 bgsfx=d->bgsfx;
2379 23298 hitsfx=d->hitsfx;
2380 23298 deadsfx=d->deadsfx;
2381 23298 bosspal=d->bosspal;
2382 23298 parent_script_UID = 0;
2383
2384 23298 frozentile = d->frozentile;
2385
2386 23298 frozencset = d->frozencset;
2387 23298 frozenclock = 0;
2388
2/2
✓ Branch 0 taken 232980 times.
✓ Branch 1 taken 23298 times.
256278 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
2389
2390
2/2
✓ Branch 0 taken 23298 times.
✓ Branch 1 taken 372768 times.
396066 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
2391 //firesfx = 0; //t.b.a -Z
2392 23298 isCore = true; //t.b.a
2393 23298 parentCore = 0; //t.b.a
2394
1/2
✓ Branch 0 taken 23298 times.
✗ Branch 1 not taken.
23298 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2395
2396 23298 firesfx = d->firesfx;
2397
2/2
✓ Branch 0 taken 745536 times.
✓ Branch 1 taken 23298 times.
768834 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
2398
2/2
✓ Branch 0 taken 745536 times.
✓ Branch 1 taken 23298 times.
768834 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
2399
2400
1/2
✓ Branch 0 taken 23298 times.
✗ Branch 1 not taken.
23298 script = (d->script >= 0) ? d->script : 0; //Dont assign invalid data.
2401 23298 waitdraw = 0;
2402
1/2
✓ Branch 0 taken 23298 times.
✗ Branch 1 not taken.
23298 weaponscript = (d->weaponscript >= 0) ? d->weaponscript : 0; //Dont assign invalid data.
2403
2404
2/2
✓ Branch 0 taken 186384 times.
✓ Branch 1 taken 23298 times.
209682 for ( int32_t q = 0; q < 8; q++ )
2405 {
2406 186384 initD[q] = d->initD[q];
2407 //Z_scripterrlog("(enemy::enemy(zfix)): Loading weapon InitD[%d] to an enemy with a value of (%d)\n",q,d->weap_initiald[q]);
2408 186384 weap_initiald[q] = d->weap_initiald[q];
2409 //al_trace("Guys.cpp: Assigning guy.initD[%d]: %d\n",q, d->initD.initD[q]);
2410 //al_trace("Guys.cpp: Assigning guy.initD[%d] from d->initD[%d]: %d\n",q,q, d->initD[q]);
2411 //al_trace("Guys.cpp: guy.initD[%d] is: %d\n",q, initD[q]);
2412 186384 }
2413
2/2
✓ Branch 0 taken 46596 times.
✓ Branch 1 taken 23298 times.
69894 for ( int32_t q = 0; q < 2; q++ )
2414 {
2415 46596 initA[q] = d->initA[q];
2416 46596 weap_initiala[q] = d->weap_initiala[q];
2417 46596 }
2418
2419 23298 stickclk = 0;
2420 23298 submerged = false;
2421 23298 ffcactivated = 0;
2422 23298 hitdir = -1;
2423 23298 dialogue_str = 0; //set by spawn flags.
2424 23298 editorflags = d->editorflags; //set by Enemy Editor
2425 //Set the drawing flag for this sprite.
2426
1/2
✓ Branch 0 taken 23298 times.
✗ Branch 1 not taken.
23298 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
2427
2428
2429
2/2
✓ Branch 0 taken 7036 times.
✓ Branch 1 taken 16262 times.
23298 if(bosspal>-1)
2430 {
2431
1/2
✓ Branch 0 taken 7036 times.
✗ Branch 1 not taken.
7036 loadpalset(csBOSS,pSprite(bosspal));
2432 7036 }
2433
2434
2/2
✓ Branch 0 taken 15842 times.
✓ Branch 1 taken 7456 times.
23298 if(bgsfx>-1)
2435 {
2436
1/2
✓ Branch 0 taken 15842 times.
✗ Branch 1 not taken.
15842 cont_sfx(bgsfx);
2437 15842 }
2438
2439
3/4
✓ Branch 0 taken 23298 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13709 times.
✓ Branch 3 taken 9589 times.
23298 if(get_bit(quest_rules,qr_NEWENEMYTILES))
2440 {
2441 13709 o_tile=d->e_tile;
2442 13709 frate = d->e_frate;
2443 13709 }
2444 else
2445 {
2446 9589 o_tile=d->tile;
2447 9589 frate = d->frate;
2448 }
2449
2450 23298 tile=0; //init to 0 here, but set it later.
2451
2452 23298 scripttile = -1;
2453 23298 scriptflip = -1;
2454 23298 do_animation = 1;
2455 23298 immortal = false;
2456 23298 noSlide = false;
2457 23298 deathexstate = -1;
2458
2459 23298 hashero=false;
2460
2461 // If they forgot the invisibility flag, here's another failsafe:
2462
3/4
✓ Branch 0 taken 1660 times.
✓ Branch 1 taken 21638 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1660 times.
23298 if(o_tile==0 && family!=eeSPINTILE)
2463 1660 flags |= guy_invisible;
2464
2465 // step = d->step/100.0;
2466 // To preserve the odd step values for Keese & Gleeok heads. -L
2467
5/8
✓ Branch 0 taken 23298 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23298 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2838 times.
✓ Branch 5 taken 20460 times.
✓ Branch 6 taken 2838 times.
✗ Branch 7 not taken.
23298 if(dstep==62.0) dstep+=0.5;
2468
5/8
✓ Branch 0 taken 20460 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20460 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 174 times.
✓ Branch 5 taken 20286 times.
✓ Branch 6 taken 174 times.
✗ Branch 7 not taken.
20460 else if(dstep==89) dstep-=1/9;
2469
2470
5/10
✓ Branch 0 taken 23298 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23298 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23298 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23298 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 23298 times.
✗ Branch 9 not taken.
23298 step = zslongToFix(dstep*100);
2471
2472
2473 23298 item_set = d->item_set;
2474 23298 grumble = d->grumble;
2475
2476
2/2
✓ Branch 0 taken 17107 times.
✓ Branch 1 taken 6191 times.
23298 if(frate == 0)
2477 6191 frate = 256;
2478
2479 23298 leader = itemguy = dying = scored = false;
2480 23298 canfreeze = count_enemy = true;
2481 23298 mainguy = !(flags & guy_doesntcount);
2482
1/2
✓ Branch 0 taken 23298 times.
✗ Branch 1 not taken.
23298 dir = zc_oldrand()&3;
2483
2484 //2.6 Enemy Editor Hit and TIle Sizes
2485
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 23298 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
23298 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
2486 //al_trace("->txsz:%i\n", d->txsz); Verified that this is setting the value. -Z
2487 // al_trace("Enemy txsz:%i\n", txsz);
2488
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 23298 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
23298 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
2489
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23298 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23298 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
2490
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23298 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23298 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hysz = d->hysz;
2491
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23298 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23298 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
2492
1/2
✓ Branch 0 taken 23298 times.
✗ Branch 1 not taken.
23298 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
2493
1/2
✓ Branch 0 taken 23298 times.
✗ Branch 1 not taken.
23298 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
2494 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
2495
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23298 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23298 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
2496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23298 times.
23298 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
2497 {
2498 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
2499 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
2500 }
2501
2502
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23298 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23298 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
2503
2504 23298 SIZEflags = d->SIZEflags;
2505
2506
7/10
✓ Branch 0 taken 23287 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 23287 times.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 11 times.
23298 if((wpn==ewBomb || wpn==ewSBomb) && family!=eeOTHER && family!=eeFIRE && (family!=eeWALK || dmisc2 != e2tBOMBCHU))
2507 wpn = 0;
2508
2509 //tile should never be 0 after init --Z (failsafe)
2510
4/6
✓ Branch 0 taken 23298 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23298 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 22830 times.
✓ Branch 5 taken 468 times.
23298 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
2511
2512 //Moveflags; for gravity and pit interaction
2513 23298 moveflags = d->moveflags;
2514
3/4
✓ Branch 0 taken 23298 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19555 times.
✓ Branch 3 taken 3743 times.
23298 if(!can_pitfall(false))
2515 {
2516 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
2517 3743 moveflags &= ~FLAG_CAN_PITFALL;
2518 3743 moveflags &= ~FLAG_CAN_WATERDROWN;
2519 3743 }
2520
2521
1/2
✓ Branch 0 taken 23298 times.
✗ Branch 1 not taken.
23298 shieldCanBlock = get_bit(quest_rules,qr_GOHMA_UNDAMAGED_BUG)?true:false;
2522 23298 }
2523
2524 //base clone constructor
2525
2526 enemy::enemy(enemy const & other, bool new_script_uid, bool clear_parent_script_UID):
2527 //Struct Element Type Purpose
2528 sprite(other),
2529 //x(other.x), //int32_t
2530 //y(other.y), //int32_t
2531 //id(other.id), //int32_t
2532 //clk(other.clk), //int32_t
2533 floor_y(other.floor_y), //int32_t
2534 fading(other.fading), //int32_t
2535 //misc(other.misc), //int32_t
2536 clk2(other.clk2), //int32_t
2537 clk3(other.clk3), //int32_t
2538 stunclk(other.stunclk), //int32_t
2539 hclk(other.hclk), //int32_t
2540 sclk(other.sclk), //int32_t
2541 superman(other.superman), //int32_t
2542 //grumble(other.grumble), //int32_t
2543 movestatus(other.movestatus), //int32_t
2544 posframe(other.posframe), //int32_t
2545 timer(other.timer), //int32_t
2546 ox(other.ox), //int32_t
2547 oy(other.oy), //int32_t
2548 //yofs(other.yofs), //int32_t
2549 did_armos(other.did_armos), //int32_t
2550 script_spawned(other.script_spawned), //int32_t
2551 d(other.d), //int32_t
2552 hp(other.hp), //int32_t
2553 starting_hp(other.starting_hp), //int32_t
2554 //flags(other.flags), //int32_t
2555
2556 flags2(other.flags2), //int32_t
2557 s_tile(other.s_tile), //int32_t
2558 family(other.family), //int32_t
2559 dcset(other.dcset), //int32_t
2560 //cs(other.cs), //int32_t
2561 anim(other.anim), //int32_t
2562 dp(other.dp), //int32_t
2563 wdp(other.wdp), //int32_t
2564 wpnsprite(other.wpnsprite), //int32_t
2565 rate(other.rate), //int32_t
2566 hrate(other.hrate), //int32_t
2567 dstep(other.dstep), //int32_t
2568
2569 homing(other.homing), //int32_t
2570 dmisc1(other.dmisc1), //int32_t
2571 dmisc2(other.dmisc2), //int32_t
2572 dmisc3(other.dmisc3), //int32_t
2573 dmisc4(other.dmisc4), //int32_t
2574 dmisc5(other.dmisc5), //int32_t
2575 dmisc6(other.dmisc6), //int32_t
2576 dmisc7(other.dmisc7), //int32_t
2577 dmisc8(other.dmisc8), //int32_t
2578 dmisc9(other.dmisc9), //int32_t
2579 dmisc10(other.dmisc10), //int32_t
2580 dmisc11(other.dmisc11), //int32_t
2581 dmisc12(other.dmisc12), //int32_t
2582 dmisc13(other.dmisc13), //int32_t
2583 dmisc14(other.dmisc14), //int32_t
2584 dmisc15(other.dmisc15), //int32_t
2585 dmisc16(other.dmisc16), //int32_t
2586 dmisc17(other.dmisc17), //int32_t
2587 dmisc18(other.dmisc18), //int32_t
2588 dmisc19(other.dmisc19), //int32_t
2589 dmisc20(other.dmisc20), //int32_t
2590 dmisc21(other.dmisc21), //int32_t
2591 dmisc22(other.dmisc22), //int32_t
2592 dmisc23(other.dmisc23), //int32_t
2593 dmisc24(other.dmisc24), //int32_t
2594 dmisc25(other.dmisc25), //int32_t
2595 dmisc26(other.dmisc26), //int32_t
2596 dmisc27(other.dmisc27), //int32_t
2597 dmisc28(other.dmisc28), //int32_t
2598 dmisc29(other.dmisc29), //int32_t
2599 dmisc30(other.dmisc30), //int32_t
2600 dmisc31(other.dmisc31), //int32_t
2601 dmisc32(other.dmisc32), //int32_t
2602 bgsfx(other.bgsfx), //int32_t
2603 hitsfx(other.hitsfx), //int32_t
2604 deadsfx(other.deadsfx), //int32_t
2605 bosspal(other.bosspal), //int32_t
2606 parent_script_UID(other.parent_script_UID), //int32_t
2607 frozentile(other.frozentile), //int32_t
2608 frozencset(other.frozencset), //int32_t
2609 frozenclock(other.frozenclock), //int32_t
2610 isCore(other.isCore), //int32_t
2611 parentCore(other.parentCore), //int32_t
2612 script_UID(other.script_UID), //int32_t
2613 firesfx(other.firesfx), //int32_t
2614 //script(other.script), //int32_t
2615 //waitdraw(other.waitdraw), //int32_t
2616 weaponscript(other.weaponscript), //int32_t
2617 stickclk(other.stickclk), //int32_t
2618 hitdir(other.hitdir), //int32_t
2619 submerged(other.submerged), //int32_t
2620 ffcactivated(other.ffcactivated), //word
2621
2622 dialogue_str(other.dialogue_str), //int32_t
2623 editorflags(other.editorflags), //int32_t
2624 //drawflags(other.drawflags), //int32_t
2625 o_tile(other.o_tile), //int32_t
2626 frate(other.frate), //int32_t
2627 //tile(other.tile), //int32_t
2628 //scripttile(other.scripttile), //int32_t
2629 //scriptflip(other.scriptflip), //int32_t
2630 //do_animation(other.do_animation), //int32_t
2631 immortal(other.immortal), //bool
2632 noSlide(other.noSlide), //bool
2633 deathexstate(other.deathexstate), //int32_t
2634 flags(other.flags), //int32_t
2635 step(other.step), //int32_t
2636
2637 item_set(other.item_set), //int32_t
2638 grumble(other.grumble), //int32_t
2639 leader(other.leader), //int32_t
2640 itemguy(other.itemguy), //int32_t
2641 dying(other.dying), //int32_t
2642 scored(other.scored), //int32_t
2643 //canfreeze(other.canfreeze), //int32_t
2644 count_enemy(other.count_enemy), //int32_t
2645 mainguy(other.mainguy), //int32_t
2646 //dir(other.dir), //int32_t
2647
2648 //txsz(other.txsz), //int32_t
2649 //tysz(other.tysz), //int32_t
2650 //hxsz(other.hxsz), //int32_t
2651 //hysz(other.hysz), //int32_t
2652 //hzsz(other.hzsz), //int32_t
2653 //hxofs(other.hxofs), //int32_t
2654 //hxofs(other.hxofs), //int32_t
2655 //xofs(other.xofs), //int32_t
2656 //yofs(other.yofs), //int32_t
2657 //hzofs(other.hzofs), //int32_t
2658 //zofs(other.zofs), //int32_t
2659
2660 wpn(other.wpn), //int32_t
2661 SIZEflags(other.SIZEflags), //int32_t
2662 hashero(other.hashero)
2663
2664 {
2665
2666 //arrays
2667
2668 if(other.scrmem)
2669 {
2670 alloc_scriptmem();
2671 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2672
2673 scrmem->scriptData = other.scrmem->scriptData;
2674 }
2675 else scrmem = NULL;
2676 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2677 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2678
2679 for(int32_t i=0; i<edefLAST255; i++)
2680 defense[i]=other.defense[i];
2681 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2682 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2683
2684 if(new_script_uid)
2685 {
2686 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2687 }
2688 if(clear_parent_script_UID)
2689 {
2690 parent_script_UID = 0;
2691 }
2692 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2693 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2694
2695 for ( int32_t q = 0; q < 8; q++ )
2696 {
2697 initD[q] = other.initD[q];
2698 weap_initiald[q] = other.weap_initiald[q];
2699 }
2700 for ( int32_t q = 0; q < 2; q++ )
2701 {
2702 initA[q] = other.initA[q];
2703 weap_initiala[q] = other.weap_initiala[q];
2704 }
2705 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
2706 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
2707 // al_trace("Enemy txsz:%i\n", txsz);
2708 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
2709 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = hxsz;
2710 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = hysz;
2711 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
2712 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
2713 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
2714 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
2715 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
2716 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
2717 {
2718 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
2719 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
2720 }
2721
2722 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
2723
2724
2725
2726
2727 }
2728
2729
2730 489 int32_t enemy::getScriptUID() { return script_UID; }
2731 void enemy::setScriptUID(int32_t new_id) { script_UID = new_id; }
2732 23284 enemy::~enemy()
2733 23284 {
2734
2/4
✓ Branch 0 taken 23284 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23284 times.
✗ Branch 3 not taken.
23284 FFCore.deallocateAllArrays(SCRIPT_NPC, getUID());
2735
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 23281 times.
23284 if(hashero)
2736 {
2737
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 Hero.setEaten(0);
2738 3 hashero=false;
2739 3 }
2740 23284 }
2741
2742
2743 bool enemy::is_move_paused()
2744 {
2745 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
2746 }
2747
2748 11304 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
2749 {
2750 11304 int32_t yg = (special==spw_floater)?8:0;
2751 11304 int32_t nb = get_bit(quest_rules, qr_NOBORDER) ? 16 : 0;
2752 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
2753
1/2
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
11304 if(input_x == -1000)
2754 input_x = dx;
2755
1/2
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
11304 if(input_y == -1000)
2756 input_y = dy;
2757
2758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11304 times.
22608 if(!(moveflags & FLAG_IGNORE_SCREENEDGE)
2759
3/6
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11304 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11304 times.
11304 && (input_x<16-nb || input_y<zc_max(16-yg-nb,0)
2760
2/4
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11304 times.
✗ Branch 3 not taken.
11304 || input_x>=240+nb-hxsz || input_y>=160+nb-hysz))
2761 return true;
2762
2763
3/6
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11304 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11304 times.
✗ Branch 5 not taken.
11304 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !kb)) //Don't walk into pits, unless being knocked back
2764 {
2765 if(ispitfall(dx,dy))
2766 return true;
2767 }
2768
2769 11304 bool flying = false;
2770 11304 bool cansolid = false;
2771
1/2
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
11304 if(moveflags & FLAG_IGNORE_SOLIDITY)
2772 cansolid = true;
2773
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11304 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11304 switch(special)
2774 {
2775 case spw_clipbottomright:
2776 if(dy>=128 || dx>=208) return true;
2777 break;
2778 case spw_clipright:
2779 break; //if(input_x>=208) return true; break;
2780
2781 case spw_wizzrobe: // fall through
2782 case spw_floater: // Special case for fliers and wizzrobes - hack!
2783 {
2784 if(isdungeon() && !(moveflags & FLAG_IGNORE_SCREENEDGE))
2785 {
2786 if(dy < 32-yg || dy >= 144) return true;
2787 if(dx < 32 || dx >= 224) return true;
2788 }
2789 if(!(moveflags & FLAG_IGNORE_BLOCKFLAGS) && flyerblocked(dx, dy, special, kb))
2790 return true;
2791 cansolid = true;
2792 flying = true;
2793 }
2794 }
2795
2796 11304 dx &= ~7;
2797 11304 dy &= ~7;
2798
2799
3/6
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11304 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11304 times.
✗ Branch 5 not taken.
11304 if(!flying && !(moveflags & FLAG_IGNORE_BLOCKFLAGS) && groundblocked(dx,dy,kb)) return true;
2800
2801
4/8
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11304 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11304 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 11304 times.
11304 if (dx < 0 || dx > 255 || dy < 0 || dy > 175)
2802 return false;
2803 //_walkflag code
2804 mapscr *s1, *s2;
2805 11304 s1=(((*tmpscr).layermap[0]-1)>=0)?tmpscr2:NULL;
2806 11304 s2=(((*tmpscr).layermap[1]-1)>=0)?tmpscr2+1:NULL;
2807
2808 11304 int32_t cpos=(dx>>4)+(dy&0xF0);
2809
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11304 times.
✓ Branch 2 taken 8964 times.
✓ Branch 3 taken 2340 times.
11304 int32_t ci = tmpscr->data[cpos], ci1 = (s1?s1:tmpscr)->data[cpos], ci2 = (s2?s2:tmpscr)->data[cpos];
2810 11304 newcombo const& c = combobuf[ci];
2811 11304 newcombo const& c1 = combobuf[ci1];
2812 11304 newcombo const& c2 = combobuf[ci2];
2813
2814 11304 int32_t b=1;
2815
2/2
✓ Branch 0 taken 5447 times.
✓ Branch 1 taken 5857 times.
11304 if(dx&8) b<<=2;
2816
2/2
✓ Branch 0 taken 5885 times.
✓ Branch 1 taken 5419 times.
11304 if(dy&8) b<<=1;
2817
2818 #define iwtr(cmb, x, y, shallow) \
2819 (shallow \
2820 ? iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, true, false) \
2821 && !iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false) \
2822 : iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false))
2823 11304 bool wtr = iwtr(ci, dx, dy, false);
2824
1/2
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
11304 bool shwtr = iwtr(ci, dx, dy, true);
2825 11304 bool pit = ispitfall(dx,dy);
2826
2827
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11304 times.
✓ Branch 2 taken 11304 times.
✗ Branch 3 not taken.
11304 bool canwtr = (moveflags & FLAG_CAN_WATERWALK) || ((moveflags & FLAG_CAN_WATERDROWN) && kb);
2828
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11304 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11304 times.
11304 bool canpit = (moveflags & FLAG_CAN_PITWALK) || ((moveflags & FLAG_CAN_PITFALL) && kb);
2829 11304 bool needwtr = (moveflags & FLAG_ONLY_WATERWALK);
2830 11304 bool needshwtr = (moveflags & FLAG_ONLY_SHALLOW_WATERWALK);
2831 11304 bool needpit = (moveflags & FLAG_ONLY_PITWALK);
2832
2833 11304 int32_t cwalkflag = c.walk & 0xF;
2834
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11304 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11304 if (c.type == cBRIDGE && get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
2835
1/2
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
11304 if (s1)
2836 {
2837 if (c1.type == cBRIDGE)
2838 {
2839 if (!get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
2840 {
2841 int efflag = (c1.walk & 0xF0)>>4;
2842 int newsolid = (c1.walk & 0xF);
2843 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
2844 }
2845 else cwalkflag &= c1.walk;
2846 }
2847 else cwalkflag |= c1.walk & 0xF;
2848 }
2849
2/2
✓ Branch 0 taken 2340 times.
✓ Branch 1 taken 8964 times.
11304 if (s2)
2850 {
2851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8964 times.
8964 if (c2.type == cBRIDGE)
2852 {
2853 if (!get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
2854 {
2855 int efflag = (c2.walk & 0xF0)>>4;
2856 int newsolid = (c2.walk & 0xF);
2857 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
2858 }
2859 else cwalkflag &= c2.walk;
2860 }
2861 8964 else cwalkflag |= c2.walk & 0xF;
2862 8964 }
2863 11304 bool solid = cwalkflag & b;
2864
3/4
✓ Branch 0 taken 1437 times.
✓ Branch 1 taken 9867 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1437 times.
11304 if (solid && !cansolid) return true;
2865
3/6
✓ Branch 0 taken 9867 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9867 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9867 times.
9867 if(needwtr || needshwtr || needpit)
2866 {
2867 bool ret = true;
2868 if (needwtr && wtr) ret = false;
2869 else if (needshwtr && shwtr) ret = false;
2870 else if (needpit && pit) ret = false;
2871 return ret;
2872 }
2873
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9867 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9867 else if(wtr && !canwtr)
2874 return true;
2875
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9867 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9867 else if(pit && !canpit)
2876 return true;
2877
2878 9867 return false;
2879 11304 }
2880
2881 4726 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
2882 {
2883
3/4
✓ Branch 0 taken 3330 times.
✓ Branch 1 taken 1396 times.
✓ Branch 2 taken 3330 times.
✗ Branch 3 not taken.
4726 if(!(dx || dy)) return true;
2884 4726 zfix bx = x+hxofs, by = y+hyofs; //left/top
2885 4726 zfix rx = bx+hxsz-1, ry = by+hysz-1; //right/bottom
2886
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4726 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4726 if(!ign_sv && dy < 0) //check gravity
2887 {
2888 if((moveflags & FLAG_OBEYS_GRAV) && isSideViewGravity())
2889 return false;
2890 }
2891
2892
3/4
✓ Branch 0 taken 1396 times.
✓ Branch 1 taken 3330 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1396 times.
4726 if(dx && !dy)
2893 {
2894
2/2
✓ Branch 0 taken 777 times.
✓ Branch 1 taken 619 times.
1396 if(dx < 0)
2895 {
2896
2/4
✓ Branch 0 taken 777 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 777 times.
777 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
2897 777 int32_t tx = (bx+dx).getFloor();
2898
2/2
✓ Branch 0 taken 1554 times.
✓ Branch 1 taken 777 times.
2331 for(zfix ty = 0; by+ty < ry; ty += 8)
2899 {
2900
1/2
✓ Branch 0 taken 1554 times.
✗ Branch 1 not taken.
1554 if(scr_walkflag(tx, by+ty, special, left, bx, by, kb))
2901 return false;
2902 1554 }
2903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 777 times.
777 if(scr_walkflag(tx, ry, special, left, bx, by, kb))
2904 return false;
2905 777 }
2906 else
2907 {
2908 619 int32_t tx = (rx+dx).getCeil();
2909
2/2
✓ Branch 0 taken 1238 times.
✓ Branch 1 taken 619 times.
1857 for(zfix ty = 0; by+ty < ry; ty += 8)
2910 {
2911
1/2
✓ Branch 0 taken 1238 times.
✗ Branch 1 not taken.
1238 if(scr_walkflag(tx, by+ty, special, right, bx, by, kb))
2912 return false;
2913 1238 }
2914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 619 times.
619 if(scr_walkflag(tx, ry, special, right, bx, by, kb))
2915 return false;
2916 }
2917 1396 }
2918
2/4
✓ Branch 0 taken 3330 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3330 times.
3330 else if(dy && !dx)
2919 {
2920
2/2
✓ Branch 0 taken 1795 times.
✓ Branch 1 taken 1535 times.
3330 if(dy < 0)
2921 {
2922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1795 times.
1795 special = (special==spw_clipbottomright)?spw_none:special;
2923 1795 int32_t ty = (by+dy).getFloor();
2924
2/2
✓ Branch 0 taken 3590 times.
✓ Branch 1 taken 1795 times.
5385 for(zfix tx = 0; bx+tx < rx; tx += 8)
2925 {
2926
1/2
✓ Branch 0 taken 3590 times.
✗ Branch 1 not taken.
3590 if(scr_walkflag(bx+tx, ty, special, up, bx, by, kb))
2927 return false;
2928 3590 }
2929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1795 times.
1795 if(scr_walkflag(rx, ty, special, up, bx, by, kb))
2930 return false;
2931 1795 }
2932 else
2933 {
2934 1535 int32_t ty = (ry+dy).getCeil();
2935
2/2
✓ Branch 0 taken 1633 times.
✓ Branch 1 taken 98 times.
1731 for(zfix tx = 0; bx+tx < rx; tx += 8)
2936 {
2937
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 1437 times.
1633 if(scr_walkflag(bx+tx, ty, special, down, bx, by, kb))
2938 1437 return false;
2939 196 }
2940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 if(scr_walkflag(rx, ty, special, down, bx, by, kb))
2941 return false;
2942 }
2943 1893 }
2944 else
2945 {
2946 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
2947 }
2948 3289 return true;
2949 4726 }
2950
2951 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
2952 {
2953 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
2954 zfix rx = bx+hxsz-1, ry = by+hysz-1; //right/bottom
2955
2956 for(zfix ty = 0; by+ty < ry; ty += 8)
2957 {
2958 for(zfix tx = 0; bx+tx < rx; tx += 8)
2959 {
2960 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
2961 return false;
2962 }
2963 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
2964 return false;
2965 }
2966 for(zfix tx = 0; bx+tx < rx; tx += 8)
2967 {
2968 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
2969 return false;
2970 }
2971 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
2972 return false;
2973 return true;
2974 }
2975
2976 3427 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
2977 {
2978 3427 bool ret = true;
2979
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3427 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3427 if(!ign_sv && dy < 0 && (moveflags & FLAG_OBEYS_GRAV) && isSideViewGravity())
2980 dy = 0;
2981
4/4
✓ Branch 0 taken 3547 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 3427 times.
✓ Branch 3 taken 179 times.
3606 while(abs(dx) > 8 || abs(dy) > 8)
2982 {
2983
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 139 times.
179 if(abs(dx) > abs(dy))
2984 {
2985 40 int32_t tdx = dx.sign() * 8;
2986
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(movexy(tdx, 0, special, kb, ign_sv))
2987 40 dx -= tdx;
2988 else
2989 {
2990 dx = tdx;
2991 ret = false;
2992 }
2993 40 }
2994 else
2995 {
2996 139 int32_t tdy = dy.sign() * 8;
2997
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 136 times.
139 if(movexy(0, tdy, special, kb, ign_sv))
2998 3 dy -= tdy;
2999 else
3000 {
3001 136 dy = tdy;
3002 136 ret = false;
3003 }
3004 }
3005 }
3006
2/2
✓ Branch 0 taken 2031 times.
✓ Branch 1 taken 1396 times.
3427 if(dx)
3007 {
3008
1/2
✓ Branch 0 taken 1396 times.
✗ Branch 1 not taken.
1396 if(scr_canmove(dx, 0, special, kb, ign_sv))
3009 1396 x += dx;
3010 else
3011 {
3012 ret = false;
3013 int32_t xsign = dx.sign();
3014 while(scr_canmove(xsign, 0, special, kb, ign_sv))
3015 {
3016 x += xsign;
3017 dx -= xsign;
3018 }
3019 if(scr_canmove(dx.decsign(), 0, special, kb, ign_sv)) //can move 0.0001 to 0.9999 px in this direction
3020 {
3021 if(dx > 0)
3022 x.doCeil();
3023 else x.doFloor();
3024 }
3025 }
3026 1396 }
3027
2/2
✓ Branch 0 taken 1055 times.
✓ Branch 1 taken 2372 times.
3427 if(dy)
3028 {
3029
2/2
✓ Branch 0 taken 1893 times.
✓ Branch 1 taken 479 times.
2372 if(scr_canmove(0, dy, special, kb, ign_sv))
3030 1893 y += dy;
3031 else
3032 {
3033 479 ret = false;
3034 479 int32_t ysign = dy.sign();
3035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 479 times.
479 while(scr_canmove(0, ysign, special, kb, ign_sv))
3036 {
3037 y += ysign;
3038 dy -= ysign;
3039 }
3040
1/2
✓ Branch 0 taken 479 times.
✗ Branch 1 not taken.
479 if(scr_canmove(0, dy.decsign(), special, kb, ign_sv)) //can move 0.0001 to 0.9999 px in this direction
3041 {
3042 if(dy > 0)
3043 y.doCeil();
3044 else y.doFloor();
3045 }
3046 }
3047 2372 }
3048 3427 return ret;
3049 }
3050
3051 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb)
3052 {
3053 zfix diagrate = zslongToFix(7071);
3054 switch(NORMAL_DIR(dir))
3055 {
3056 case up:
3057 return movexy(0, -px, special, kb);
3058 case down:
3059 return movexy(0, px, special, kb);
3060 case left:
3061 return movexy(-px, 0, special, kb);
3062 case right:
3063 return movexy(px, 0, special, kb);
3064 case r_up:
3065 return movexy(px*diagrate, -px*diagrate, special, kb);
3066 case r_down:
3067 return movexy(px*diagrate, px*diagrate, special, kb);
3068 case l_up:
3069 return movexy(-px*diagrate, -px*diagrate, special, kb);
3070 case l_down:
3071 return movexy(-px*diagrate, px*diagrate, special, kb);
3072 }
3073 return false;
3074 }
3075
3076 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
3077 {
3078 double v = degrees.getFloat() * PI / 180.0;
3079 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
3080 return movexy(dx, dy, special, kb);
3081 }
3082
3083 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
3084 {
3085 zfix tx = x, ty = y;
3086 bool ret = movexy(dx, dy, special, kb);
3087 x = tx;
3088 y = ty;
3089 return ret;
3090 }
3091 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
3092 {
3093 zfix tx = x, ty = y;
3094 bool ret = moveDir(dir, px, special, kb);
3095 x = tx;
3096 y = ty;
3097 return ret;
3098 }
3099 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
3100 {
3101 zfix tx = x, ty = y;
3102 bool ret = moveAtAngle(degrees, px, special, kb);
3103 x = tx;
3104 y = ty;
3105 return ret;
3106 }
3107
3108 // Handle pitfalls
3109 10715186 bool enemy::do_falling(int32_t index)
3110 {
3111
1/2
✓ Branch 0 taken 10715186 times.
✗ Branch 1 not taken.
10715186 if(fallclk > 0)
3112 {
3113 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
3114 if(!--fallclk)
3115 {
3116 if(immortal) //Keep alive forever
3117 ++fallclk; //force another frame of falling.... forever.
3118 else if(dying) //Give 1 frame for script revival
3119 {
3120 if(flags&guy_neverret)
3121 never_return(index);
3122
3123 if(leader)
3124 kill_em_all();
3125
3126 //leave_item(); //Don't drop items in pits!
3127 stop_bgsfx(index);
3128 return true;
3129 }
3130 else
3131 {
3132 try_death(true); //Force death
3133 ++fallclk; //force another frame of falling
3134 }
3135 }
3136
3137 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
3138 cs = spr.csets & 0xF;
3139 int32_t fr = spr.frames ? spr.frames : 1;
3140 int32_t spd = spr.speed ? spr.speed : 1;
3141 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
3142 tile = spr.tile + zc_min(animclk / spd, fr-1);
3143 }
3144 10715186 return false;
3145 10715186 }
3146
3147 // Handle drowning in water
3148 10715186 bool enemy::do_drowning(int32_t index)
3149 {
3150
1/2
✓ Branch 0 taken 10715186 times.
✗ Branch 1 not taken.
10715186 if(drownclk > 0)
3151 {
3152 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x.getInt()));
3153 //!TODO: Drown SFX
3154 if(!--drownclk)
3155 {
3156 if(immortal) //Keep alive forever
3157 ++drownclk; //force another frame of falling.... forever.
3158 else if(dying) //Give 1 frame for script revival
3159 {
3160 if(flags&guy_neverret)
3161 never_return(index);
3162
3163 if(leader)
3164 kill_em_all();
3165
3166 //leave_item(); //Don't drop items in pits!
3167 stop_bgsfx(index);
3168 return true;
3169 }
3170 else
3171 {
3172 try_death(true); //Force death
3173 ++drownclk; //force another frame of falling
3174 }
3175 }
3176
3177 if (drownCombo && combobuf[drownCombo].usrflags&cflag1)
3178 {
3179 wpndata &spr = wpnsbuf[QMisc.sprites[sprLAVADROWN]];
3180 cs = spr.csets & 0xF;
3181 int32_t fr = spr.frames ? spr.frames : 1;
3182 int32_t spd = spr.speed ? spr.speed : 1;
3183 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
3184 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
3185 }
3186 else
3187 {
3188 wpndata &spr = wpnsbuf[QMisc.sprites[sprDROWN]];
3189 cs = spr.csets & 0xF;
3190 int32_t fr = spr.frames ? spr.frames : 1;
3191 int32_t spd = spr.speed ? spr.speed : 1;
3192 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
3193 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
3194 }
3195 }
3196 10715186 return false;
3197 10715186 }
3198
3199 // Supplemental animation code that all derived classes should call
3200 // as a return value for animate().
3201 // Handles the death animation and returns true when enemy is finished.
3202 10922486 bool enemy::Dead(int32_t index)
3203 {
3204
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 10920657 times.
10922486 if(immortal)
3205 {
3206 1829 dying = false;
3207 1829 return false;
3208 }
3209
2/2
✓ Branch 0 taken 221404 times.
✓ Branch 1 taken 10699253 times.
10920657 if(dying)
3210 {
3211
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 221404 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
221404 if(deathexstate > -1 && deathexstate < 32)
3212 {
3213 setxmapflag(1<<deathexstate);
3214 deathexstate = -1;
3215 }
3216 221404 --clk2;
3217
3218
4/4
✓ Branch 0 taken 218786 times.
✓ Branch 1 taken 2618 times.
✓ Branch 2 taken 11122 times.
✓ Branch 3 taken 314 times.
221404 if((get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
3219
2/2
✓ Branch 0 taken 11436 times.
✓ Branch 1 taken 207350 times.
218786 && hp>-1000) // not killed by ringleader
3220 11122 death_sfx();
3221
3222
2/2
✓ Branch 0 taken 209821 times.
✓ Branch 1 taken 11583 times.
221404 if(clk2==0)
3223 {
3224
2/2
✓ Branch 0 taken 11347 times.
✓ Branch 1 taken 236 times.
11583 if(flags&guy_neverret)
3225 236 never_return(index);
3226
3227
2/2
✓ Branch 0 taken 11540 times.
✓ Branch 1 taken 43 times.
11583 if(leader)
3228 43 kill_em_all();
3229
3230 11583 leave_item();
3231 11583 }
3232
3233 221404 stop_bgsfx(index);
3234 221404 return (clk2==0);
3235 }
3236
3237 10699253 return false;
3238 10922486 }
3239
3240 // Basic animation code that all derived classes should call.
3241 // The one with an index is the one that is called by
3242 // the guys sprite list; index is the enemy's index in the list.
3243 10882340 bool enemy::animate(int32_t index)
3244 {
3245
2/2
✓ Branch 0 taken 765604 times.
✓ Branch 1 taken 10116736 times.
10882340 if(sclk <= 0) hitdir = -1;
3246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10882340 times.
10882340 if(switch_hooked)
3247 {
3248 if(get_bit(quest_rules, qr_SWITCHOBJ_RUN_SCRIPT))
3249 {
3250 //Run its script
3251 if (run_script(MODE_NORMAL)==RUNSCRIPT_SELFDELETE)
3252 {
3253 return 0; //Avoid NULLPO if this object deleted itself
3254 }
3255 }
3256 return false;
3257 }
3258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10882340 times.
10882340 if(do_falling(index)) return true;
3259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10882340 times.
10882340 else if(fallclk)
3260 {
3261 //clks
3262 if(hclk>0)
3263 --hclk;
3264 if(stunclk>0)
3265 --stunclk;
3266 if ( frozenclock > 0 )
3267 --frozenclock;
3268 if(hashero)
3269 {
3270 Hero.setX(x);
3271 Hero.setY(y);
3272 Hero.fallCombo = fallCombo;
3273 Hero.fallclk = fallclk;
3274 hashero = false; //Let Hero go if falling
3275 }
3276 run_script(MODE_NORMAL);
3277 return false;
3278 }
3279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10882340 times.
10882340 if(do_drowning(index)) return true;
3280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10882340 times.
10882340 else if(drownclk)
3281 {
3282 //clks
3283 if(hclk>0)
3284 --hclk;
3285 if(stunclk>0)
3286 --stunclk;
3287 if ( frozenclock > 0 )
3288 --frozenclock;
3289 if(hashero)
3290 {
3291 Hero.setX(x);
3292 Hero.setY(y);
3293 Hero.drownclk = drownclk;
3294 hashero = false; //Let Hero go if falling
3295 }
3296 run_script(MODE_NORMAL);
3297 return false;
3298 }
3299 10882340 int32_t nx = real_x(x);
3300 10882340 int32_t ny = real_y(y);
3301
3302
4/4
✓ Branch 0 taken 7845279 times.
✓ Branch 1 taken 3037061 times.
✓ Branch 2 taken 1373557 times.
✓ Branch 3 taken 9218836 times.
10882340 if(ox!=nx || oy!=ny)
3303 {
3304 4410618 posframe=(posframe+1)%(get_bit(quest_rules,qr_NEWENEMYTILES)?4:2);
3305 4410618 }
3306
3307 13629454 ox = nx;
3308 13629454 oy = ny;
3309
3310 // Maybe they fell off the bottom in sideview, or were moved by a script.
3311
3312 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
3313
2/2
✓ Branch 0 taken 2916097 times.
✓ Branch 1 taken 10713357 times.
13629454 if ( immortal )
3314 {
3315 //skip, as it can go out of bounds, from immortality
3316 2916097 }
3317
2/6
✓ Branch 0 taken 10713357 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10713357 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
10713357 else if ( (moveflags & FLAG_IGNORE_SCREENEDGE) || (( (get_bit(quest_rules, qr_OUTOFBOUNDSENEMIES)) != (editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
3318 {
3319 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
3320 }
3321
7/10
✓ Branch 0 taken 10689057 times.
✓ Branch 1 taken 24300 times.
✓ Branch 2 taken 10713357 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10713357 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10713357 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6 times.
✓ Branch 9 taken 10713351 times.
10713357 else if ( (OUTOFBOUNDS) )
3322 {
3323 6 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
3324 6 }
3325 //fall down
3326
6/6
✓ Branch 0 taken 5351142 times.
✓ Branch 1 taken 8278312 times.
✓ Branch 2 taken 5231065 times.
✓ Branch 3 taken 8398389 times.
✓ Branch 4 taken 207375 times.
✓ Branch 5 taken 5023690 times.
13629454 if((enemycanfall(id) || (moveflags & FLAG_OBEYS_GRAV) )&& fading != fade_flicker && clk>=0)
3327 {
3328
2/2
✓ Branch 0 taken 24000 times.
✓ Branch 1 taken 4999690 times.
5023690 if(isSideViewGravity())
3329 {
3330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24000 times.
24000 if(get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE))
3331 {
3332 if(!isOnSideviewPlatform())
3333 {
3334 bool willHitSVPlatform = false;
3335 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH)?hxsz:16;
3336 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT)?hysz:16;
3337 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
3338 {
3339 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
3340 {
3341 willHitSVPlatform = true;
3342 break;
3343 }
3344 }
3345 if(willHitSVPlatform)
3346 {
3347 y+=fall/100;
3348 //y-=int32_t(y)%16; //Fix to top of SV Ladder
3349 do_fix(y, 16); //Fix to top of SV Ladder
3350 fall = 0;
3351 }
3352 else
3353 {
3354 y+=fall/100;
3355 if(fall <= (int32_t)zinit.terminalv)
3356 fall += (zinit.gravity2/100);
3357 }
3358 }
3359 else
3360 {
3361 if(fall!=0) // Only fix pos once
3362 {
3363 //y-=(int32_t)y%8; // Fix position
3364 do_fix(y, 8); //Fix position
3365 }
3366
3367 fall = 0;
3368 }
3369 }
3370 else
3371 {
3372
2/2
✓ Branch 0 taken 22585 times.
✓ Branch 1 taken 1415 times.
24000 if(isOnSideviewPlatform())
3373 22585 fall = 0;
3374 else
3375 {
3376 1415 zfix fall_amnt = fall/100;
3377 1415 bool hit = false;
3378
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 1819 times.
3201 while(fall_amnt >= 1)
3379 {
3380 1819 --fall_amnt;
3381 1819 ++y;
3382
2/2
✓ Branch 0 taken 1786 times.
✓ Branch 1 taken 33 times.
1819 if(isOnSideviewPlatform())
3383 {
3384 33 y = y.getInt();
3385 33 fall_amnt = 0;
3386 33 hit = true;
3387 33 break;
3388 }
3389 }
3390
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 1302 times.
1415 if(fall_amnt > 0)
3391 1302 y += fall_amnt;
3392
1/2
✓ Branch 0 taken 1415 times.
✗ Branch 1 not taken.
1415 if(fall_amnt < 0)
3393 {
3394 if(!movexy(0,fall_amnt,spw_none))
3395 hit = true;
3396 }
3397
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1382 times.
1415 if(hit)
3398 33 fall = 0;
3399
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 1105 times.
1382 else if(fall <= (int32_t)zinit.terminalv)
3400 1105 fall += (zinit.gravity2/100);
3401 }
3402 }
3403 24000 }
3404 else
3405 {
3406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4999690 times.
4999690 if (!(moveflags & FLAG_NO_FAKE_Z))
3407 {
3408
2/2
✓ Branch 0 taken 2539420 times.
✓ Branch 1 taken 2460270 times.
4999690 if(fakefall!=0)
3409 2460270 fakez-=(fakefall/100);
3410
3411
2/2
✓ Branch 0 taken 2460270 times.
✓ Branch 1 taken 2539420 times.
4999690 if(fakez<0)
3412 2460270 fakez = fakefall = 0;
3413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2539420 times.
2539420 else if(fakefall <= (int32_t)zinit.terminalv)
3414 2539420 fakefall += (zinit.gravity2/100);
3415
3416
5/6
✓ Branch 0 taken 4999690 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2539420 times.
✓ Branch 3 taken 2460270 times.
✓ Branch 4 taken 2465843 times.
✓ Branch 5 taken 73577 times.
4999690 if (fakez<=0 && fakefall > 0 && !get_bit(quest_rules, qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
3417 4999690 }
3418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4999690 times.
4999690 if (!(moveflags & FLAG_NO_REAL_Z))
3419 {
3420
2/2
✓ Branch 0 taken 2549697 times.
✓ Branch 1 taken 2449993 times.
4999690 if(fall!=0)
3421 2449993 z-=(fall/100);
3422
3423
2/2
✓ Branch 0 taken 2449993 times.
✓ Branch 1 taken 2549697 times.
4999690 if(z<0)
3424 2449993 z = fall = 0;
3425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2549697 times.
2549697 else if(fall <= (int32_t)zinit.terminalv)
3426 2549697 fall += (zinit.gravity2/100);
3427
3428
6/6
✓ Branch 0 taken 4999652 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 2549659 times.
✓ Branch 3 taken 2449993 times.
✓ Branch 4 taken 2476082 times.
✓ Branch 5 taken 73577 times.
4999690 if (z<=0 && fall > 0 && !get_bit(quest_rules, qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
3429 4999690 }
3430
3431 }
3432 5023690 }
3433
4/4
✓ Branch 0 taken 10690886 times.
✓ Branch 1 taken 2938568 times.
✓ Branch 2 taken 3153654 times.
✓ Branch 3 taken 13844540 times.
13629454 if(!isSideViewGravity() && (moveflags & FLAG_CAN_PITFALL))
3434 {
3435
8/10
✓ Branch 0 taken 4616895 times.
✓ Branch 1 taken 9227645 times.
✓ Branch 2 taken 4616857 times.
✓ Branch 3 taken 38 times.
✓ Branch 4 taken 4616857 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 4616895 times.
✓ Branch 8 taken 4616857 times.
✓ Branch 9 taken 4616857 times.
13844540 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
3436 {
3437 4616857 fallCombo = check_pits();
3438 4616857 }
3439 23078254 }
3440
3/4
✓ Branch 0 taken 10690886 times.
✓ Branch 1 taken 24300 times.
✓ Branch 2 taken 10690886 times.
✗ Branch 3 not taken.
10715186 if(!isSideViewGravity() && (moveflags & FLAG_CAN_WATERDROWN))
3441 {
3442 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
3443 {
3444 drownCombo = check_water();
3445 }
3446 }
3447
3448 10715186 runKnockback(); //scripted knockback handling
3449
3450 // clk is incremented here
3451
2/2
✓ Branch 0 taken 10163964 times.
✓ Branch 1 taken 551222 times.
10715186 if(++clk >= frate)
3452 551222 clk=0;
3453
3454 // hit and death handling
3455
2/2
✓ Branch 0 taken 10301155 times.
✓ Branch 1 taken 414031 times.
10715186 if(hclk>0)
3456 414031 --hclk;
3457
3458
2/2
✓ Branch 0 taken 10501752 times.
✓ Branch 1 taken 213434 times.
10715186 if(stunclk>0)
3459 213434 --stunclk;
3460
1/2
✓ Branch 0 taken 10715186 times.
✗ Branch 1 not taken.
10715186 if ( frozenclock > 0 )
3461 --frozenclock;
3462
3463
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 10715186 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
10715186 if(ceiling && z <= 0 && fakez <= 0)
3464 ceiling = false;
3465
3466 10715186 try_death();
3467
3468 10715186 scored=false;
3469
3470 10715186 ++c_clk;
3471
3472 //Run its script
3473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10715186 times.
10715186 if (run_script(MODE_NORMAL)==RUNSCRIPT_SELFDELETE)
3474 {
3475 return 0; //Avoid NULLPO if this object deleted itself
3476 }
3477
3478 // returns true when enemy is defeated
3479 10715186 return Dead(index);
3480 10715186 }
3481
3482 10939482 bool enemy::setSolid(bool set)
3483 {
3484
1/2
✓ Branch 0 taken 10939482 times.
✗ Branch 1 not taken.
10939482 bool actual = set && !isSubmerged();
3485 10939482 bool ret = solid_object::setSolid(actual);
3486 10939482 solid = set;
3487 10939482 return ret;
3488 }
3489 void enemy::doContactDamage(int32_t hdir)
3490 {
3491 Hero.hithero(guys.find(this), hdir);
3492 }
3493
3494 87210 void enemy::solid_push(solid_object *obj)
3495 {
3496
1/2
✓ Branch 0 taken 87210 times.
✗ Branch 1 not taken.
87210 if(obj == this) return; //can't push self
3497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87210 times.
87210 if(moveflags&FLAG_NOT_PUSHABLE) return; //not pushable
3498 87210 zfix dx, dy;
3499 87210 int32_t hdir = -1;
3500 87210 solid_push_int(obj,dx,dy,hdir);
3501
3502
4/4
✓ Branch 0 taken 85854 times.
✓ Branch 1 taken 1356 times.
✓ Branch 2 taken 83962 times.
✓ Branch 3 taken 1892 times.
87210 if(!dx && !dy) return;
3503
3504 3248 bool t = obj->getTempNonsolid();
3505 3248 obj->setTempNonsolid(true);
3506
3507 3248 int32_t ydir = dy > 0 ? down : up;
3508 3248 int32_t xdir = dx > 0 ? right : left;
3509
3510 3248 auto special = isflier(id) ? spw_floater : spw_none;
3511
2/2
✓ Branch 0 taken 2905 times.
✓ Branch 1 taken 343 times.
3248 if(!movexy(dx,dy,special,true,true))
3512 {
3513 //Crushed?
3514 343 }
3515
3516 3248 obj->setTempNonsolid(t);
3517 87210 }
3518 87210 bool enemy::is_unpushable() const
3519 {
3520 87210 return isSubmerged();
3521 }
3522 87210 bool enemy::sideview_mode() const
3523 {
3524
3/4
✓ Branch 0 taken 24300 times.
✓ Branch 1 taken 62910 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24300 times.
87210 return isSideViewGravity() && (moveflags&FLAG_OBEYS_GRAV) && !(moveflags&FLAG_NOT_PUSHABLE);
3525 }
3526
3527 1259 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
3528 {
3529 1259 int32_t yg = (special==spw_floater)?8:0;
3530 1259 int32_t nb = get_bit(quest_rules, qr_NOBORDER) ? 16 : 0;
3531
3532
8/10
✓ Branch 0 taken 1002 times.
✓ Branch 1 taken 257 times.
✓ Branch 2 taken 201 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 257 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 257 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1002 times.
✓ Branch 9 taken 1259 times.
1259 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
3533 2004 return true;
3534
3535 1259 bool isInDungeon = isdungeon();
3536
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1259 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1259 if(isInDungeon || special==spw_wizzrobe)
3537 {
3538
7/8
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1003 times.
✓ Branch 2 taken 251 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 257 times.
✓ Branch 5 taken 751 times.
✓ Branch 6 taken 257 times.
✗ Branch 7 not taken.
1259 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
3539 508 return true;
3540
3541
7/8
✓ Branch 0 taken 250 times.
✓ Branch 1 taken 501 times.
✓ Branch 2 taken 251 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 251 times.
✓ Branch 5 taken 251 times.
✓ Branch 6 taken 251 times.
✗ Branch 7 not taken.
751 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
3542
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
502 if(special!=spw_door) // walk in door way
3543 return true;
3544 251 }
3545
3546
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 251 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
251 if(!(moveflags & FLAG_CAN_PITWALK) && !(moveflags & FLAG_CAN_PITFALL)) //Don't walk into pits (knockback doesn't call this func)
3547 {
3548 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
3549 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
3550 return true;
3551 }
3552
3553
1/4
✓ Branch 0 taken 251 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
251 switch(special)
3554 {
3555 case spw_clipbottomright:
3556 if(dy>=128 || dx>=208) return true;
3557 break;
3558 case spw_clipright:
3559 break; //if(x>=208) return true; break;
3560
3561 case spw_wizzrobe: // fall through
3562 case spw_floater: // Special case for fliers and wizzrobes - hack!
3563 {
3564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 251 times.
251 if(isInDungeon)
3565 {
3566
2/4
✓ Branch 0 taken 251 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 251 times.
251 if(dy < 32-yg || dy >= 144) return true;
3567
2/4
✓ Branch 0 taken 251 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 251 times.
251 if(dx < 32 || dx >= 224) return true;
3568 251 }
3569 251 return false;
3570 }
3571 }
3572
3573 dx&=(special==spw_halfstep)?(~7):(~15);
3574 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
3575
3576 if(special==spw_water)
3577 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
3578
3579 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
3580 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
3581 257 }
3582
3583 487 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
3584 {
3585 487 bool kb = false;
3586 487 int32_t nb = get_bit(quest_rules, qr_NOBORDER) ? 16 : 0;
3587
3588
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 487 times.
✓ Branch 2 taken 379 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 487 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 487 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 487 times.
487 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=240+nb || dy>=160+nb)
3589 return true;
3590
3591
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 439 times.
487 if(isdungeon())
3592 {
3593
2/4
✓ Branch 0 taken 439 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 439 times.
439 if((dy<32) || (dy>=144))
3594 return true;
3595
3596
2/4
✓ Branch 0 taken 439 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 439 times.
439 if((dx<32) || (dx>=224))
3597 return true;
3598 439 }
3599
3600
2/4
✓ Branch 0 taken 487 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 487 times.
487 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL))) //Don't walk into pits, unless being knocked back
3601 {
3602
2/4
✓ Branch 0 taken 487 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 487 times.
974 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
3603
2/4
✓ Branch 0 taken 487 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 487 times.
✗ Branch 3 not taken.
487 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
3604 return true;
3605 487 }
3606
3607
1/2
✓ Branch 0 taken 487 times.
✗ Branch 1 not taken.
487 if(get_bit(quest_rules,qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
3608 {
3609
3/4
✓ Branch 0 taken 475 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 475 times.
✗ Branch 3 not taken.
962 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
3610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
475 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
3611 }
3612 else
3613 {
3614 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
3615 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
3616 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
3617 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
3618 }
3619 487 }
3620
3621 12172222 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
3622 {
3623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12172222 times.
12172222 if(moveflags & FLAG_USE_NEW_MOVEMENT)
3624 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
3625 12172222 int32_t yg = (special==spw_floater)?8:0;
3626 12172222 int32_t nb = get_bit(quest_rules, qr_NOBORDER) ? 16 : 0;
3627
2/2
✓ Branch 0 taken 1055475 times.
✓ Branch 1 taken 11116747 times.
12172222 switch(dir)
3628 {
3629 case l_down:
3630 case r_down:
3631 case down:
3632 case 11: //r_down
3633 case 12: //down
3634 case 13: //l_down
3635 {
3636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1055475 times.
1055475 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
3637 {
3638
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1055475 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1055475 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT && !isflier(id) )
3639 {
3640 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
3641 dy += zc_max(hysz-16,0);
3642 }
3643 1055475 }
3644 1055475 break;
3645 }
3646 }
3647
2/2
✓ Branch 0 taken 1079195 times.
✓ Branch 1 taken 11093027 times.
12172222 switch(dir)
3648 {
3649 case r_up:
3650 case r_down:
3651 case right:
3652 case 9: //r_up
3653 case 10: //right
3654 case 11: //r_down
3655 {
3656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1079195 times.
1079195 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
3657 {
3658
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1079195 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1079195 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH && !isflier(id) )
3659 {
3660 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
3661 dx += zc_max(hxsz-16,0);
3662 }
3663 1079195 }
3664 1079195 break;
3665 }
3666 }
3667 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
3668
3669
10/10
✓ Branch 0 taken 9374089 times.
✓ Branch 1 taken 2798133 times.
✓ Branch 2 taken 994991 times.
✓ Branch 3 taken 1803142 times.
✓ Branch 4 taken 2796216 times.
✓ Branch 5 taken 1917 times.
✓ Branch 6 taken 2794351 times.
✓ Branch 7 taken 1865 times.
✓ Branch 8 taken 9379346 times.
✓ Branch 9 taken 12173697 times.
12172222 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
3670 18757217 return true;
3671
3672 12173697 bool isInDungeon = isdungeon();
3673
4/4
✓ Branch 0 taken 281657 times.
✓ Branch 1 taken 11892040 times.
✓ Branch 2 taken 480 times.
✓ Branch 3 taken 281177 times.
12173697 if(isInDungeon || special==spw_wizzrobe)
3674 {
3675
8/8
✓ Branch 0 taken 2449402 times.
✓ Branch 1 taken 9443118 times.
✓ Branch 2 taken 2365075 times.
✓ Branch 3 taken 84327 times.
✓ Branch 4 taken 2423039 times.
✓ Branch 5 taken 7104406 times.
✓ Branch 6 taken 2423025 times.
✓ Branch 7 taken 14 times.
11892520 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=144 && dy>=144))
3676 4788100 return true;
3677
3678
8/8
✓ Branch 0 taken 2391469 times.
✓ Branch 1 taken 4712951 times.
✓ Branch 2 taken 2325962 times.
✓ Branch 3 taken 65507 times.
✓ Branch 4 taken 2370450 times.
✓ Branch 5 taken 2408008 times.
✓ Branch 6 taken 2370447 times.
✓ Branch 7 taken 3 times.
7104420 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<224 && dx>=224))
3679
2/2
✓ Branch 0 taken 44455 times.
✓ Branch 1 taken 30 times.
4696409 if(special!=spw_door) // walk in door way
3680 44455 return true;
3681 2408041 }
3682
3683
6/6
✓ Branch 0 taken 388388 times.
✓ Branch 1 taken 2300830 times.
✓ Branch 2 taken 353653 times.
✓ Branch 3 taken 34735 times.
✓ Branch 4 taken 30948 times.
✓ Branch 5 taken 322705 times.
2689218 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !kb)) //Don't walk into pits, unless being knocked back
3684 {
3685
2/4
✓ Branch 0 taken 357440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 357440 times.
714880 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
3686
2/4
✓ Branch 0 taken 357440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 357440 times.
✗ Branch 3 not taken.
357440 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
3687 return true;
3688 357440 }
3689
3690
3/4
✓ Branch 0 taken 2276855 times.
✓ Branch 1 taken 410091 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2272 times.
2689218 switch(special)
3691 {
3692 case spw_clipbottomright:
3693 if(dy>=128 || dx>=208) return true;
3694 break;
3695 case spw_clipright:
3696 2272 break; //if(input_x>=208) return true; break;
3697
3698 case spw_wizzrobe: // fall through
3699 case spw_floater: // Special case for fliers and wizzrobes - hack!
3700 {
3701
2/2
✓ Branch 0 taken 179459 times.
✓ Branch 1 taken 2097396 times.
2276855 if(isInDungeon)
3702 {
3703
3/4
✓ Branch 0 taken 2097386 times.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2097386 times.
2097396 if(dy < 32-yg || dy >= 144) return true;
3704
3/4
✓ Branch 0 taken 2096880 times.
✓ Branch 1 taken 506 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2096880 times.
2097386 if(dx < 32 || dx >= 224) return true;
3705 2096880 }
3706 2276339 return false;
3707 }
3708 }
3709
3710 412363 dx&=(special==spw_halfstep)?(~7):(~15);
3711
2/2
✓ Branch 0 taken 89683 times.
✓ Branch 1 taken 322680 times.
412363 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
3712
3713
2/2
✓ Branch 0 taken 16387 times.
✓ Branch 1 taken 395976 times.
412363 if(special==spw_water)
3714
2/2
✓ Branch 0 taken 3319 times.
✓ Branch 1 taken 13068 times.
16387 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
3715
3716
2/2
✓ Branch 0 taken 391053 times.
✓ Branch 1 taken 4923 times.
395976 if(get_bit(quest_rules,qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
3717 {
3718
4/4
✓ Branch 0 taken 310989 times.
✓ Branch 1 taken 80064 times.
✓ Branch 2 taken 308486 times.
✓ Branch 3 taken 2503 times.
699539 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
3719
2/2
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 308025 times.
308486 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
3720 }
3721 else
3722 {
3723
4/4
✓ Branch 0 taken 4062 times.
✓ Branch 1 taken 861 times.
✓ Branch 2 taken 3954 times.
✓ Branch 3 taken 108 times.
8877 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
3724
4/4
✓ Branch 0 taken 3827 times.
✓ Branch 1 taken 127 times.
✓ Branch 2 taken 3814 times.
✓ Branch 3 taken 13 times.
3954 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
3725
3/4
✓ Branch 0 taken 3730 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 3730 times.
✗ Branch 3 not taken.
3814 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
3726
1/2
✓ Branch 0 taken 3730 times.
✗ Branch 1 not taken.
3730 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
3727 }
3728 2800662 }
3729
3730 40823 bool enemy::isOnSideviewPlatform()
3731 {
3732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40823 times.
40823 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hxsz : 16;
3733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40823 times.
40823 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hysz : 16;
3734
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 40823 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
40823 if(y + usehei >= 176 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true; //Bottom of the map
3735
2/2
✓ Branch 0 taken 2205 times.
✓ Branch 1 taken 38618 times.
40823 if(check_slope(x, y+1, usewid, usehei)) return true;
3736
2/2
✓ Branch 0 taken 38618 times.
✓ Branch 1 taken 4373 times.
42991 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
3737 {
3738
2/2
✓ Branch 0 taken 4373 times.
✓ Branch 1 taken 34245 times.
38618 if(_walkflag(nx,y+usehei,1)) return true;
3739
3/4
✓ Branch 0 taken 4373 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3971 times.
✓ Branch 3 taken 402 times.
4373 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
3740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 402 times.
402 if(checkSVLadderPlatform(nx,y+usehei)) return true;
3741 402 }
3742 4373 return false;
3743 40823 }
3744
3745 // Stops playing the given sound only if there are no enemies left to play it
3746 222671 void enemy::stop_bgsfx(int32_t index)
3747 {
3748
2/2
✓ Branch 0 taken 215902 times.
✓ Branch 1 taken 6769 times.
222671 if(bgsfx<=0)
3749 215902 return;
3750
3751 // Look for other enemies with the same bgsfx
3752
2/2
✓ Branch 0 taken 32350 times.
✓ Branch 1 taken 3454 times.
35804 for(int32_t i=0; i<guys.Count(); i++)
3753 {
3754
4/4
✓ Branch 0 taken 28003 times.
✓ Branch 1 taken 4347 times.
✓ Branch 2 taken 3315 times.
✓ Branch 3 taken 24688 times.
32350 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
3755 3315 return;
3756 29035 }
3757
3758 3454 stop_sfx(bgsfx);
3759 222671 }
3760
3761
3762 // to allow for different sfx on defeating enemy
3763 11273 void enemy::death_sfx()
3764 {
3765
1/2
✓ Branch 0 taken 11273 times.
✗ Branch 1 not taken.
11273 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
3766 11273 }
3767
3768 void enemy::move(zfix dx,zfix dy)
3769 {
3770 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
3771 {
3772 switch(family)
3773 {
3774 case eeFIRE:
3775 case eeOTHER:
3776 return;
3777 default: break;
3778 }
3779 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
3780 }
3781 */
3782 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & FLAG_OBEYS_GRAV) || !enemycanfall(id)))
3783 {
3784 x+=dx;
3785 y+=dy;
3786 }
3787 }
3788
3789 5313522 void enemy::move(zfix s)
3790 {
3791 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
3792 {
3793 switch(family)
3794 {
3795 case eeFIRE:
3796 case eeOTHER:
3797 return;
3798 default: break;
3799 }
3800 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
3801 }*/
3802
8/10
✓ Branch 0 taken 5313501 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 15004 times.
✓ Branch 3 taken 5298497 times.
✓ Branch 4 taken 1172 times.
✓ Branch 5 taken 13832 times.
✓ Branch 6 taken 1172 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1172 times.
✗ Branch 9 not taken.
5313522 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & FLAG_OBEYS_GRAV)))
3803 {
3804 5312329 sprite::move(s);
3805 5312329 }
3806 5313522 }
3807
3808 11655 void enemy::leave_item()
3809 {
3810 11655 int32_t drop_item = select_dropitem(item_set, x, y);
3811 11655 int32_t thedropset = item_set;
3812
3813 11655 std::vector<int32_t> &ev = FFCore.eventData;
3814 11655 ev.clear();
3815 11655 ev.push_back(getUID());
3816 11655 ev.push_back(drop_item*10000);
3817 11655 ev.push_back(thedropset*10000);
3818
3819 11655 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
3820 11655 drop_item = vbound(ev[1] / 10000,-2,255);
3821 11655 thedropset = ev[2] / 10000;
3822 11655 ev.clear();
3823
1/2
✓ Branch 0 taken 11655 times.
✗ Branch 1 not taken.
11655 if(drop_item == -2)
3824 {
3825 drop_item = select_dropitem(thedropset,x,y);
3826 }
3827
3828
6/6
✓ Branch 0 taken 4556 times.
✓ Branch 1 taken 7099 times.
✓ Branch 2 taken 191 times.
✓ Branch 3 taken 4365 times.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 176 times.
11655 if(drop_item>=0&&((itemsbuf[drop_item].family!=itype_fairy)||!m_walkflag(x,y,0,dir)))
3829 {
3830 item* itm;
3831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4541 times.
4541 if (get_bit(quest_rules, qr_ENEMY_DROPS_USE_HITOFFSETS))
3832 {
3833 itm = (new item(x+hxofs+(hxsz/2)-8,y+hyofs+(hysz/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
3834 }
3835 else
3836 {
3837
8/14
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 4482 times.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 59 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 59 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 59 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 59 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 59 times.
✗ Branch 13 not taken.
4541 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
3838
4/8
✓ Branch 0 taken 4482 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4482 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4482 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4482 times.
✗ Branch 7 not taken.
4482 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
3839 }
3840 4541 itm->from_dropset = thedropset;
3841 4541 items.add(itm);
3842
3843 4541 ev.push_back(getUID());
3844 4541 ev.push_back(itm->getUID());
3845
3846 4541 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
3847 4541 ev.clear();
3848 4541 }
3849 11655 }
3850
3851 // auomatically kill off enemy (for rooms with ringleaders)
3852 182 void enemy::kickbucket()
3853 {
3854
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 10 times.
182 if(!superman)
3855 172 hp=-1000; // don't call death_sfx()
3856 182 }
3857
3858 87210 bool enemy::isSubmerged() const
3859 {
3860 87210 return submerged;
3861 //!TODO SOLIDPUSH more things like teleporting wizzrobes
3862 }
3863
3864 15942 void enemy::FireBreath(bool seekhero)
3865 {
3866
1/2
✓ Branch 0 taken 15942 times.
✗ Branch 1 not taken.
15942 if(wpn==wNone)
3867 return;
3868
3869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15942 times.
15942 if(wpn==ewFireTrail)
3870 {
3871 dmisc1 = e1tEACHTILE;
3872 FireWeapon();
3873 return;
3874 }
3875
3876 15942 float fire_angle=0.0;
3877 15942 int32_t wx=0, wy=0, wdir=dir;
3878
3879
2/2
✓ Branch 0 taken 374 times.
✓ Branch 1 taken 15568 times.
15942 if(!seekhero)
3880 {
3881
4/5
✓ Branch 0 taken 3242 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2996 times.
✓ Branch 3 taken 5212 times.
✓ Branch 4 taken 4118 times.
15568 switch(dir)
3882 {
3883 case down:
3884 2996 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
3885 2996 wx=x;
3886 2996 wy=y+8;
3887 2996 break;
3888
3889 case -1:
3890 case up:
3891 3242 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
3892 3242 wx=x;
3893 3242 wy=y-8;
3894 3242 break;
3895
3896 case left:
3897 5212 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
3898 5212 wx=x-8;
3899 5212 wy=y;
3900 5212 break;
3901
3902 case right:
3903 4118 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
3904 4118 wx=x+8;
3905 4118 wy=y;
3906 4118 break;
3907 }
3908
3909
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15568 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15568 if(wpn==ewFlame || wpn==ewFlame2)
3910 {
3911
2/4
✓ Branch 0 taken 15568 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15568 times.
15568 if(fire_angle==-PI || fire_angle==PI) wdir=left;
3912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15568 times.
15568 else if(fire_angle==-PI/2) wdir=up;
3913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15568 times.
15568 else if(fire_angle==PI/2) wdir=down;
3914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15568 times.
15568 else if(fire_angle==0) wdir=right;
3915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15568 times.
15568 else if(fire_angle<-PI/2) wdir=l_up;
3916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15568 times.
15568 else if(fire_angle<0) wdir=r_up;
3917
2/2
✓ Branch 0 taken 1475 times.
✓ Branch 1 taken 14093 times.
15568 else if(fire_angle<(PI/2)) wdir=r_down;
3918
2/2
✓ Branch 0 taken 10026 times.
✓ Branch 1 taken 4067 times.
14093 else if(fire_angle<PI) wdir=l_down;
3919 15568 }
3920 15568 }
3921 else
3922 {
3923 374 wx = x;
3924 374 wy = y;
3925 }
3926
3927
2/2
✓ Branch 0 taken 374 times.
✓ Branch 1 taken 15568 times.
15942 addEwpn(wx,wy,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
3928 15942 sfx(wpnsfx(wpn),pan(int32_t(x)));
3929
3930 15942 int32_t i=Ewpns.Count()-1;
3931 15942 weapon *ew = (weapon*)(Ewpns.spr(i));
3932 15942 ew->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
3933
3934
4/4
✓ Branch 0 taken 15568 times.
✓ Branch 1 taken 374 times.
✓ Branch 2 taken 7767 times.
✓ Branch 3 taken 7801 times.
15942 if(!seekhero && (zc_oldrand()&4))
3935 {
3936 7801 ew->angular=true;
3937 7801 ew->angle=fire_angle;
3938 7801 }
3939
3940
4/4
✓ Branch 0 taken 15885 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 15568 times.
15942 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
3941 {
3942 15568 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
3943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15568 times.
15568 if ( ew->do_animation ) ew->tile+=ew->aframe;
3944 15568 }
3945
3946
2/2
✓ Branch 0 taken 15942 times.
✓ Branch 1 taken 531888 times.
547830 for(int32_t j=Ewpns.Count()-1; j>0; j--)
3947 {
3948 531888 Ewpns.swap(j,j-1);
3949 531888 }
3950 15942 }
3951
3952 14548 void enemy::FireWeapon()
3953 {
3954 /*
3955 * Type:
3956 * 0x01: Boss fireball
3957 * 0x02: Seeks Hero
3958 * 0x04: Fast projectile
3959 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
3960 */
3961
3962
1/2
✓ Branch 0 taken 14548 times.
✗ Branch 1 not taken.
14548 if (wpn < 1) return;
3963
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 14548 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
14548 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
3964 return;
3965
3966
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14548 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
14548 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
3967 dmisc1 = e1tEACHTILE;
3968
3969 14548 int32_t xoff = 0;
3970 14548 int32_t yoff = 0;
3971
1/2
✓ Branch 0 taken 14548 times.
✗ Branch 1 not taken.
14548 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH )
3972 {
3973 xoff += (hxsz/2)-8;
3974 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
3975 }
3976
1/2
✓ Branch 0 taken 14548 times.
✗ Branch 1 not taken.
14548 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT )
3977 {
3978 yoff += (hysz/2)-8;
3979 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
3980 }
3981
3982
4/8
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 13232 times.
✓ Branch 2 taken 494 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 409 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
14548 switch(dmisc1)
3983 {
3984 case e1t5SHOTS: //BS-Aquamentus
3985 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
3986 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
3987 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
3988 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
3989
3990 [[fallthrough]];
3991 case e1t3SHOTSFAST:
3992 case e1t3SHOTS: //Aquamentus
3993
7/14
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 413 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 413 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 413 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 413 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 413 times.
✗ Branch 13 not taken.
413 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
3994 413 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
3995
7/14
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 413 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 413 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 413 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 413 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 413 times.
✗ Branch 13 not taken.
413 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
3996 413 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
3997
3998 [[fallthrough]];
3999 default:
4000
11/20
✓ Branch 0 taken 13645 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13645 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13645 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13645 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 13645 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 13645 times.
✓ Branch 12 taken 13645 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 8010 times.
✓ Branch 15 taken 5635 times.
✓ Branch 16 taken 13645 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 13645 times.
✗ Branch 19 not taken.
13645 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
4001 13645 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4002 13645 sfx(wpnsfx(wpn),pan(int32_t(x)));
4003 13645 break;
4004
4005 case e1tSLANT:
4006 {
4007 409 int32_t slant = 0;
4008
4009
10/10
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 197 times.
✓ Branch 3 taken 212 times.
✓ Branch 4 taken 45 times.
✓ Branch 5 taken 152 times.
✓ Branch 6 taken 60 times.
✓ Branch 7 taken 304 times.
✓ Branch 8 taken 131 times.
✓ Branch 9 taken 173 times.
409 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
4010 236 slant = left;
4011
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 79 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 109 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 27 times.
✓ Branch 6 taken 51 times.
✓ Branch 7 taken 85 times.
✓ Branch 8 taken 24 times.
✓ Branch 9 taken 61 times.
173 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
4012 112 slant = right;
4013
4014
9/18
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 319 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 319 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 319 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 319 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 319 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 319 times.
✓ Branch 14 taken 319 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 319 times.
✗ Branch 17 not taken.
319 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
4015 319 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4016 319 sfx(wpnsfx(wpn),pan(int32_t(x)));
4017 319 break;
4018 }
4019
4020 case e1t8SHOTS: //Fire Wizzrobe
4021 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
4022 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4023 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4024 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
4025 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4026 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4027 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
4028 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4029 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4030 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
4031 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4032 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4033
4034 [[fallthrough]];
4035 case e1t4SHOTS: //Stalfos 3
4036
7/14
✓ Branch 0 taken 494 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 494 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 494 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 494 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 494 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 494 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 494 times.
✗ Branch 13 not taken.
494 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
4037 494 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4038 494 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4039
7/14
✓ Branch 0 taken 494 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 494 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 494 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 494 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 494 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 494 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 494 times.
✗ Branch 13 not taken.
494 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
4040 494 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4041 494 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4042
7/14
✓ Branch 0 taken 494 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 494 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 494 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 494 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 494 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 494 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 494 times.
✗ Branch 13 not taken.
494 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
4043 494 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4044 494 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4045
7/14
✓ Branch 0 taken 494 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 494 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 494 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 494 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 494 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 494 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 494 times.
✗ Branch 13 not taken.
494 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
4046 494 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4047 494 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4048 494 sfx(wpnsfx(wpn),pan(int32_t(x)));
4049 494 break;
4050
4051 case e1tSUMMON: // Bat Wizzrobe
4052 {
4053 //al_trace("Summon Bats\n");
4054 //zprint2("Summon Bats\n");
4055 if(dmisc4==0) break; // Summon 0
4056
4057 int32_t bc=0;
4058
4059 for(int32_t gc=0; gc<guys.Count(); gc++)
4060 {
4061 if((((enemy*)guys.spr(gc))->id) == dmisc3)
4062 {
4063 ++bc;
4064 }
4065 }
4066
4067 if(bc<=40) // Not too many enemies
4068 {
4069 int32_t kids = guys.Count();
4070 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
4071
4072 for(int32_t i=0; i<bats; i++)
4073 {
4074 //zprint2("summon\n");
4075 //al_trace("summon\n");
4076 if(addchild(x,y,dmisc3,-10, this->script_UID))
4077 {
4078 ((enemy*)guys.spr(kids+i))->count_enemy = false;
4079 //((enemy*)guys.spr(guys.Count()-1))->parent_script_UID = this->script_UID;
4080 //zprint2("Summoner Script UID: %d\n",this->script_UID);
4081
4082 }
4083 }
4084
4085 sfx(get_bit(quest_rules,qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
4086 }
4087
4088 break;
4089 }
4090
4091 case e1tSUMMONLAYER: // Summoner
4092 {
4093 if(count_layer_enemies()==0)
4094 {
4095 break;
4096 }
4097
4098 int32_t kids = guys.Count();
4099
4100 if(kids<40)
4101 {
4102 int32_t newguys=(zc_oldrand()%3)+1;
4103 bool summoned=false;
4104
4105 for(int32_t i=0; i<newguys; i++)
4106 {
4107 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
4108 int32_t x2=0;
4109 int32_t y2=0;
4110
4111 for(int32_t k=0; k<20; ++k)
4112 {
4113 x2=16*((zc_oldrand()%12)+2);
4114 y2=16*((zc_oldrand()%7)+2);
4115
4116 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
4117 {
4118 //zprint2("summon\n");
4119 //al_trace("summon\n");
4120 if(addchild(x2,y2,get_bit(quest_rules,qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
4121 {
4122 ((enemy*)guys.spr(kids+i))->count_enemy = false;
4123 //((enemy*)guys.spr(guys.Count()-1))->parent_script_UID = this->script_UID;
4124 if (get_bit(quest_rules,qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & FLAG_USE_FAKE_Z))
4125 {
4126 ((enemy*)guys.spr(kids+i))->fakez = 64;
4127 ((enemy*)guys.spr(kids+i))->z = 0;
4128 }
4129 }
4130
4131 summoned=true;
4132 break;
4133 }
4134 }
4135 }
4136
4137 if(summoned)
4138 {
4139 sfx(get_bit(quest_rules,qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
4140 }
4141 }
4142
4143 break;
4144 }
4145 }
4146 14458 }
4147
4148
4149 // Hit the shield(s)?
4150 // Apparently, this function is only used for hookshots...
4151 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
4152 {
4153 if(!(family==eeWALK || family==eeFIRE || family==eeOTHER))
4154 return false;
4155
4156 bool ret = false;
4157
4158 // TODO: There must be some bitwise operations that can simplify this...
4159 if(wpny > y) ret = ((flags&inv_front && xdir==down) || (flags&inv_back && xdir==up) || (flags&inv_left && xdir==left) || (flags&inv_right && xdir==right));
4160 else if(wpny < y) ret = ((flags&inv_front && xdir==up) || (flags&inv_back && xdir==down) || (flags&inv_left && xdir==right) || (flags&inv_right && xdir==left));
4161
4162 if(wpnx < x) ret = ret || ((flags&inv_front && xdir==left) || (flags&inv_back && xdir==right) || (flags&inv_left && xdir==up) || (flags&inv_right && xdir==down));
4163 else if(wpnx > x) ret = ret || ((flags&inv_front && xdir==right) || (flags&inv_back && xdir==left) || (flags&inv_left && xdir==down) || (flags&inv_right && xdir==up));
4164
4165 return ret;
4166 }
4167
4168
4169 //! Weapon Editor for 2.6
4170 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
4171
4172
4173 //converts a wqeapon ID to its defence index.
4174 41565 int32_t weaponToDefence(int32_t wid)
4175 {
4176
14/44
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 19464 times.
✓ Branch 3 taken 4190 times.
✓ Branch 4 taken 11181 times.
✓ Branch 5 taken 502 times.
✓ Branch 6 taken 27 times.
✓ Branch 7 taken 48 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 387 times.
✓ Branch 10 taken 4539 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 99 times.
✓ Branch 14 taken 504 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 152 times.
✓ Branch 18 taken 383 times.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 12 times.
✓ Branch 34 taken 77 times.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
41565 switch(wid)
4177 {
4178 case wNone: return -1;
4179 19464 case wSword: return edefSWORD;
4180 4190 case wBeam: return edefBEAM;
4181 11181 case wBrang: return edefBRANG;
4182 502 case wBomb: return edefBOMB;
4183 27 case wSBomb: return edefSBOMB;
4184 48 case wLitBomb: return edefBOMB;
4185 case wLitSBomb: return edefSBOMB;
4186 387 case wArrow: return edefARROW;
4187 4539 case wFire: return edefFIRE;
4188 case wWhistle:
4189 {
4190 //al_trace("Weapon resolved as a whistle, using edef: %s\n", "edefWhistle");
4191 return edefWhistle;
4192 }
4193 case wBait: return edefBAIT;
4194 99 case wWand: return edefWAND;
4195 504 case wMagic: return edefMAGIC;
4196 case wCatching: return -1;
4197 case wWind: return edefWIND;
4198 152 case wRefMagic: return edefREFMAGIC;
4199 383 case wRefFireball: return edefREFBALL;
4200 case wRefRock: return edefREFROCK;
4201 case wHammer: return edefHAMMER;
4202 case wHookshot: return edefHOOKSHOT;
4203 case wHSHandle: return edefHOOKSHOT;
4204 case wHSChain: return edefHOOKSHOT;
4205 case wSSparkle: return edefSPARKLE;
4206 case wFSparkle: return edefSPARKLE;
4207 case wSmack: return -1; // is this the candle object?
4208 case wPhantom: return -1; //engine created visual effects.
4209 case wCByrna: return edefBYRNA;
4210 case wRefBeam: return edefREFBEAM;
4211 case wStomp: return edefSTOMP;
4212 case wScript1: return edefSCRIPT01;
4213 case wScript2: return edefSCRIPT02;
4214 12 case wScript3: return edefSCRIPT03;
4215 77 case wScript4: return edefSCRIPT04;
4216 case wScript5: return edefSCRIPT05;
4217 case wScript6: return edefSCRIPT06;
4218 case wScript7: return edefSCRIPT07;
4219 case wScript8: return edefSCRIPT08;
4220 case wScript9: return edefSCRIPT09;
4221 case wScript10: return edefSCRIPT10;
4222 case wIce: return edefICE;
4223 case wSound: return edefSONIC;
4224 case wThrown: return edefTHROWN;
4225 //case wPot: return edefPOT;
4226 // case wLitZap: return edefELECTRIC;
4227 // case wZ3Sword: return edefZ3SWORD;
4228 // case wLASWord: return edefLASWORD;
4229 // case wSpinAttk: return edefSPINATTK;
4230 // case wShield: return edefSHIELD;
4231 // case wTrowel: return edefTROWEL;
4232
4233 default: return -1;
4234 }
4235 41565 }
4236
4237 41565 int32_t getDefType(weapon *w)
4238 {
4239 41565 int32_t id = getWeaponID(w);
4240 41565 int32_t edef = weaponToDefence(id);
4241
1/2
✓ Branch 0 taken 41565 times.
✗ Branch 1 not taken.
41565 if(edef == edefHOOKSHOT)
4242 {
4243 if(w->family_class == itype_switchhook)
4244 return edefSwitchHook;
4245 }
4246 41565 return edef;
4247 41565 }
4248
4249 71949 int32_t getWeaponID(weapon *w)
4250 {
4251 71949 int32_t usewpn = w->useweapon;
4252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71949 times.
71949 return (usewpn > 0) ? usewpn : w->id;
4253 }
4254
4255 41565 int32_t enemy::resolveEnemyDefence(weapon *w)
4256 {
4257 //sword edef is 9, but we're reading it at 0
4258 //,
4259 41565 int32_t weapondef = 0;
4260 41565 int32_t wdeftype = getDefType(w);
4261 41565 int32_t usedef = w->usedefence;
4262
4263
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 41565 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
41565 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
4264 {
4265 weapondef = usedef*-1;
4266 }
4267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41565 times.
41565 else if(unsigned(wdeftype) < edefLAST255)
4268 {
4269 41565 weapondef = wdeftype;
4270 41565 }
4271 41565 return weapondef;
4272 }
4273
4274 45655 byte get_def_ignrflag(int32_t edef)
4275 {
4276
3/3
✓ Branch 0 taken 38758 times.
✓ Branch 1 taken 725 times.
✓ Branch 2 taken 6172 times.
45655 switch(edef)
4277 {
4278 case edIGNORE:
4279 case edIGNOREL1:
4280 case edSTUNORIGNORE:
4281 6172 return WPNUNB_IGNR;
4282 case edSTUNORCHINK:
4283 case edCHINK:
4284 case edCHINKL1:
4285 case edCHINKL2:
4286 case edCHINKL4:
4287 case edCHINKL6:
4288 case edCHINKL8:
4289 case edCHINKL10:
4290 case edLEVELCHINK2:
4291 case edLEVELCHINK3:
4292 case edLEVELCHINK4:
4293 case edLEVELCHINK5:
4294 725 return WPNUNB_BLOCK;
4295 }
4296 38758 return 0;
4297 45655 }
4298
4299 45655 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
4300 {
4301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45655 times.
45655 if(!(unblockable&get_def_ignrflag(edef))) return edef;
4302 switch(edef)
4303 {
4304 case edIGNORE:
4305 case edIGNOREL1:
4306 case edCHINK:
4307 case edCHINKL1:
4308 case edCHINKL2:
4309 case edCHINKL4:
4310 case edCHINKL6:
4311 case edCHINKL8:
4312 case edCHINKL10:
4313 case edLEVELCHINK2:
4314 case edLEVELCHINK3:
4315 case edLEVELCHINK4:
4316 case edLEVELCHINK5:
4317 return edNORMAL;
4318 case edSTUNORIGNORE:
4319 case edSTUNORCHINK:
4320 return edSTUNONLY;
4321 }
4322 return edef;
4323 45655 }
4324
4325 // Do we do damage?
4326 // 0: takehit returns 0
4327 // 1: takehit returns 1
4328 // -1: do damage
4329 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
4330 41565 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
4331 {
4332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41565 times.
41565 if(switch_hooked) return 0;
4333 41565 int32_t tempx = x;
4334 41565 int32_t tempy = y;
4335 41565 int32_t the_defence = 0;
4336
1/2
✓ Branch 0 taken 41565 times.
✗ Branch 1 not taken.
41565 if ( edef < 0 ) //we are using a specific base default defence for a weapon
4337 {
4338 the_defence = edef*-1; //A specific defence type.
4339 }
4340 41565 else the_defence = defense[edef];
4341
4342 41565 the_defence = conv_edef_unblockable(the_defence, unblockable);
4343
4344
3/4
✓ Branch 0 taken 2757 times.
✓ Branch 1 taken 38808 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2757 times.
41565 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
4345 {
4346
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2756 times.
✓ Branch 2 taken 1 times.
2757 switch(the_defence)
4347 {
4348 case edIGNORE:
4349 1 return 0;
4350 case edIGNOREL1:
4351 case edSTUNORIGNORE:
4352 if(*power <= 0)
4353 return 0;
4354 }
4355 2756 sfx(WAV_CHINK,pan(int32_t(x)));
4356 2756 return 1;
4357 }
4358
4359 38808 int32_t new_id = id;
4360 38808 int32_t effect_type = dmisc15;
4361 38808 int32_t delay_timer = 90;
4362 38808 enemy *gleeok = NULL;
4363 38808 enemy *ptra = NULL;
4364 38808 int32_t c = 0;
4365
4366
13/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 717 times.
✓ Branch 6 taken 440 times.
✓ Branch 7 taken 21 times.
✓ Branch 8 taken 62 times.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 52 times.
✓ Branch 13 taken 5454 times.
✓ Branch 14 taken 69 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 565 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 71 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 56 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 31185 times.
38808 switch(the_defence)
4367 {
4368 case edREPLACE:
4369 {
4370 sclk = 0;
4371 if ( dmisc16 > 0 ) new_id = dmisc16;
4372 else new_id = id+1;
4373 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
4374 if ( dmisc17 > 0 ) delay_timer = dmisc17;
4375 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
4376
4377 //Z_scripterrlog("new id is %d\n", new_id);
4378 switch(guysbuf[new_id&0xFFF].family)
4379 {
4380 //Fixme: possible enemy memory leak. (minor)
4381 case eeWALK:
4382 {
4383 enemy *e = new eStalfos(x,y,new_id,clk);
4384 guys.add(e);
4385 }
4386 break;
4387
4388 case eeLEV:
4389 {
4390 enemy *e = new eLeever(x,y,new_id,clk);
4391 guys.add(e);
4392 }
4393 break;
4394
4395 case eeTEK:
4396 {
4397 enemy *e = new eTektite(x,y,new_id,clk);
4398 guys.add(e);
4399 }
4400 break;
4401
4402 case eePEAHAT:
4403 {
4404 enemy *e = new ePeahat(x,y,new_id,clk);
4405 guys.add(e);
4406 }
4407 break;
4408
4409 case eeZORA:
4410 {
4411 enemy *e = new eZora(x,y,new_id,clk);
4412 guys.add(e);
4413 }
4414 break;
4415
4416 case eeGHINI:
4417 {
4418 enemy *e = new eGhini(x,y,new_id,clk);
4419 guys.add(e);
4420 }
4421 break;
4422
4423 case eeKEESE:
4424 {
4425 enemy *e = new eKeese(x,y,new_id,clk);
4426 guys.add(e);
4427 }
4428 break;
4429
4430 case eeWIZZ:
4431 {
4432 enemy *e = new eWizzrobe(x,y,new_id,clk);
4433 guys.add(e);
4434 }
4435 break;
4436
4437 case eePROJECTILE:
4438 {
4439 enemy *e = new eProjectile(x,y,new_id,clk);
4440 guys.add(e);
4441 }
4442 break;
4443
4444 case eeWALLM:
4445 {
4446 enemy *e = new eWallM(x,y,new_id,clk);
4447 guys.add(e);
4448 }
4449 break;
4450
4451 case eeAQUA:
4452 {
4453 enemy *e = new eAquamentus(x,y,new_id,clk);
4454 guys.add(e);
4455 e->x = x;
4456 e->y = y;
4457 }
4458 break;
4459
4460 case eeMOLD:
4461 {
4462 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1)));
4463 guys.add(e);
4464 e->x = x;
4465 e->y = y;
4466 }
4467 break;
4468
4469 case eeMANHAN:
4470 {
4471 enemy *e = new eManhandla(x,y,new_id,clk);
4472 guys.add(e);
4473 e->x = x;
4474 e->y = y;
4475 }
4476 break;
4477
4478 case eeGLEEOK:
4479 {
4480 *power = 0;
4481 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].misc1);
4482 guys.add(gleeok);
4483 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
4484 //((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
4485 new_id &= 0xFFF;
4486 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1));
4487 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
4488 for(int32_t i=0; i<head_cnt; i++)
4489 {
4490 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
4491 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
4492 {
4493 al_trace("Gleeok head %d could not be created!\n",i+1);
4494
4495 for(int32_t j=0; j<i+1; j++)
4496 {
4497 guys.del(guys.Count()-1);
4498 }
4499
4500 break;
4501 }
4502 else
4503 {
4504 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
4505 //((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
4506 }
4507
4508 c-=guysbuf[new_id].misc4;
4509 //gleeok->x = x;
4510 //gleeok->y = y;
4511 //gleeok = e;
4512 }
4513 return 1;
4514 }
4515
4516 case eeGHOMA:
4517 {
4518 enemy *e = new eGohma(x,y,new_id,clk);
4519 guys.add(e);
4520 e->x = x;
4521 e->y = y;
4522 }
4523 break;
4524
4525 case eeLANM:
4526 {
4527 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].misc1)));
4528 guys.add(e);
4529 e->x = x;
4530 e->y = y;
4531 }
4532 break;
4533
4534 case eeGANON:
4535 {
4536 enemy *e = new eGanon(x,y,new_id,clk);
4537 guys.add(e);
4538 e->x = x;
4539 e->y = y;
4540 }
4541 break;
4542
4543 case eeFAIRY:
4544 {
4545 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
4546 guys.add(e);
4547 e->x = x;
4548 e->y = y;
4549 }
4550 break;
4551
4552 case eeFIRE:
4553 {
4554 enemy *e = new eFire(x,y,new_id,clk);
4555 guys.add(e);
4556 e->x = x;
4557 e->y = y;
4558 }
4559 break;
4560
4561 case eeOTHER:
4562 {
4563 enemy *e = new eOther(x,y,new_id,clk);
4564 guys.add(e);
4565 e->x = x;
4566 e->y = y;
4567 }
4568 break;
4569
4570 case eeSPINTILE:
4571 {
4572 enemy *e = new eSpinTile(x,y,new_id,clk);
4573 guys.add(e);
4574 e->x = x;
4575 e->y = y;
4576 }
4577 break;
4578
4579 // and these enemies use the misc10/misc2 value
4580 case eeROCK:
4581 {
4582 switch(guysbuf[new_id&0xFFF].misc10)
4583 {
4584 case 1:
4585 {
4586 enemy *e = new eBoulder(x,y,new_id,clk);
4587 guys.add(e);
4588 e->x = x;
4589 e->y = y;
4590 }
4591 break;
4592
4593 case 0:
4594 default:
4595 {
4596 enemy *e = new eRock(x,y,new_id,clk);
4597 guys.add(e);
4598 e->x = x;
4599 e->y = y;
4600 }
4601 break;
4602 }
4603
4604 break;
4605 }
4606
4607 case eeTRAP:
4608 {
4609 switch(guysbuf[new_id&0xFFF].misc2)
4610 {
4611 case 1:
4612 {
4613 enemy *e = new eTrap2(x,y,new_id,clk);
4614 guys.add(e);
4615 e->x = x;
4616 e->y = y;
4617 }
4618 break;
4619
4620 case 0:
4621 default:
4622 {
4623 enemy *e = new eTrap(x,y,new_id,clk);
4624 guys.add(e);
4625 e->x = x;
4626 e->y = y;
4627 }
4628 break;
4629 }
4630
4631 break;
4632 }
4633
4634 case eeDONGO:
4635 {
4636 switch(guysbuf[new_id&0xFFF].misc10)
4637 {
4638 case 1:
4639 {
4640 enemy *e = new eDodongo2(x,y,new_id,clk);
4641 guys.add(e);
4642 e->x = x;
4643 e->y = y;
4644 }
4645 break;
4646
4647 case 0:
4648 default:
4649 {
4650 enemy *e = new eDodongo(x,y,new_id,clk);
4651 guys.add(e);
4652 e->x = x;
4653 e->y = y;
4654 }
4655 break;
4656 }
4657
4658 break;
4659 }
4660
4661 case eeDIG:
4662 {
4663 switch(guysbuf[new_id&0xFFF].misc10)
4664 {
4665 case 1:
4666 {
4667 enemy *e = new eLilDig(x,y,new_id,clk);
4668 guys.add(e);
4669 e->x = x;
4670 e->y = y;
4671 }
4672 break;
4673
4674 case 0:
4675 default:
4676 {
4677 enemy *e = new eBigDig(x,y,new_id,clk);
4678 guys.add(e);
4679 e->x = x;
4680 e->y = y;
4681 }
4682 break;
4683 }
4684
4685 break;
4686 }
4687
4688 case eePATRA:
4689 {
4690 switch(guysbuf[new_id&0xFFF].misc10)
4691 {
4692 case 1:
4693 {
4694 if (get_bit(quest_rules,qr_HARDCODED_BS_PATRA))
4695 {
4696 enemy *e = new ePatraBS(x,y,new_id,clk);
4697 guys.add(e);
4698 e->x = x;
4699 e->y = y;
4700 break;
4701 }
4702 }
4703 [[fallthrough]];
4704 case 0:
4705 default:
4706 {
4707 enemy *e = new ePatra(x,y,new_id,clk);
4708 guys.add(e);
4709 e->x = x;
4710 e->y = y;
4711 }
4712 break;
4713 }
4714
4715 break;
4716 }
4717
4718 case eeGUY:
4719 {
4720 switch(guysbuf[new_id&0xFFF].misc10)
4721 {
4722 case 1:
4723 {
4724 enemy *e = new eTrigger(x,y,new_id,clk);
4725 guys.add(e);
4726 }
4727 break;
4728
4729 case 0:
4730 default:
4731 {
4732 enemy *e = new eNPC(x,y,new_id,clk);
4733 guys.add(e);
4734 }
4735 break;
4736 }
4737
4738 break;
4739 }
4740
4741 case eeSCRIPT01:
4742 case eeSCRIPT02:
4743 case eeSCRIPT03:
4744 case eeSCRIPT04:
4745 case eeSCRIPT05:
4746 case eeSCRIPT06:
4747 case eeSCRIPT07:
4748 case eeSCRIPT08:
4749 case eeSCRIPT09:
4750 case eeSCRIPT10:
4751 case eeSCRIPT11:
4752 case eeSCRIPT12:
4753 case eeSCRIPT13:
4754 case eeSCRIPT14:
4755 case eeSCRIPT15:
4756 case eeSCRIPT16:
4757 case eeSCRIPT17:
4758 case eeSCRIPT18:
4759 case eeSCRIPT19:
4760 case eeSCRIPT20:
4761 {
4762 enemy *e = new eScript(x,y,new_id,clk);
4763 guys.add(e);
4764 e->x = x;
4765 e->y = y;
4766 break;
4767 }
4768
4769
4770 case eeFFRIENDLY01:
4771 case eeFFRIENDLY02:
4772 case eeFFRIENDLY03:
4773 case eeFFRIENDLY04:
4774 case eeFFRIENDLY05:
4775 case eeFFRIENDLY06:
4776 case eeFFRIENDLY07:
4777 case eeFFRIENDLY08:
4778 case eeFFRIENDLY09:
4779 case eeFFRIENDLY10:
4780 {
4781 enemy *e = new eFriendly(x,y,new_id,clk);
4782 guys.add(e);
4783 e->x = x;
4784 e->y = y;
4785 break;
4786 }
4787
4788
4789 default: break;
4790 }
4791
4792 // add segments of segmented enemies
4793 int32_t c=0;
4794
4795 switch(guysbuf[new_id&0xFFF].family)
4796 {
4797 case eeMOLD:
4798 {
4799 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
4800 new_id &= 0xFFF;
4801
4802 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].misc1)); i++)
4803 {
4804 //christ this is messy -DD
4805 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
4806
4807 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
4808 {
4809 al_trace("Moldorm segment %d could not be created!\n",i+1);
4810
4811 for(int32_t j=0; j<i+1; j++)
4812 guys.del(guys.Count()-1);
4813
4814 return 0;
4815 }
4816
4817 if(i>0)
4818 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
4819
4820
4821 }
4822
4823 break;
4824 }
4825
4826 case eeLANM:
4827 {
4828 new_id &= 0xFFF;
4829 int32_t shft = guysbuf[new_id].misc2;
4830 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
4831 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
4832
4833 if(!guys.add(e))
4834 {
4835 al_trace("Lanmola segment 1 could not be created!\n");
4836 guys.del(guys.Count()-1);
4837 return 0;
4838 }
4839 e->x = x;
4840 e->y = y;
4841
4842
4843
4844 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].misc1)); i++)
4845 {
4846 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
4847 if(!guys.add(e2))
4848 {
4849 al_trace("Lanmola segment %d could not be created!\n",i+1);
4850
4851 for(int32_t j=0; j<i+1; j++)
4852 guys.del(guys.Count()-1);
4853
4854 return 0;
4855 }
4856 e2->x = x;
4857 e2->y = y;
4858
4859 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
4860
4861 }
4862 }
4863 break;
4864
4865 case eeMANHAN:
4866 new_id &= 0xFFF;
4867
4868 for(int32_t i=0; i<((!(guysbuf[new_id].misc2))?4:8); i++)
4869 {
4870 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
4871 {
4872 al_trace("Manhandla head %d could not be created!\n",i+1);
4873
4874 for(int32_t j=0; j<i+1; j++)
4875 {
4876 guys.del(guys.Count()-1);
4877 }
4878
4879 return 0;
4880 }
4881
4882
4883 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].misc1;
4884 }
4885
4886 break;
4887
4888 case eeGLEEOK:
4889 {
4890 /*
4891 new_id &= 0xFFF;
4892 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1));
4893 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
4894 for(int32_t i=0; i<head_cnt; i++)
4895 {
4896 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
4897 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
4898 {
4899 al_trace("Gleeok head %d could not be created!\n",i+1);
4900
4901 for(int32_t j=0; j<i+1; j++)
4902 {
4903 guys.del(guys.Count()-1);
4904 }
4905
4906 break;
4907 }
4908
4909 c-=guysbuf[new_id].misc4;
4910 */
4911
4912 // }
4913 }
4914 break;
4915
4916
4917 case eePATRA:
4918 {
4919 new_id &= 0xFFF;
4920 int32_t outeyes = 0;
4921 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
4922
4923 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].misc1); i++)
4924 {
4925 if(!((guysbuf[new_id].misc10&&get_bit(quest_rules,qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
4926 {
4927 al_trace("Patra outer eye %d could not be created!\n",i+1);
4928
4929 for(int32_t j=0; j<i+1; j++)
4930 guys.del(guys.Count()-1);
4931
4932 return 0;
4933 }
4934 else
4935 outeyes++;
4936
4937
4938 }
4939
4940 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].misc2); i++)
4941 {
4942 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
4943 {
4944 al_trace("Patra inner eye %d could not be created!\n",i+1);
4945
4946 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
4947 guys.del(guys.Count()-1);
4948
4949 return 0;
4950 }
4951
4952
4953 }
4954 delete ptra;
4955 break;
4956 }
4957 }
4958
4959
4960
4961 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
4962 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
4963 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
4964 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
4965 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
4966 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
4967 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
4968 //((enemy*)guys.spr(guys.Count()-1))->mainguy = this->mainguy; //This might mean that it is a core.
4969 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
4970 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
4971 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
4972 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
4973 ((enemy*)guys.spr(guys.Count()-1))->script_UID = this->script_UID;
4974 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
4975
4976
4977 item_set = 0; //Do not make a drop.
4978
4979 switch(effect_type)
4980 {
4981 case -7:
4982 {
4983 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
4984 Lwpns.add(w);
4985 break;
4986 }
4987 case -6:
4988 {
4989 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
4990 Lwpns.add(w);
4991 break;
4992 }
4993 case -5:
4994 {
4995 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
4996 Lwpns.add(w);
4997 break;
4998 }
4999 case -4:
5000 {
5001 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
5002 Lwpns.add(w);
5003 break;
5004 }
5005 case -3: explode(1); break;
5006 case -2: explode(2); break;
5007 case -1: explode(0); break;
5008 case 0: break;
5009
5010 default:
5011 {
5012 //Dummy weapon function
5013 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
5014 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
5015 Lwpns.add(w);
5016 break;
5017 }
5018 }
5019
5020
5021 yofs = -32768;
5022 switch(guysbuf[new_id&0xFFF].family)
5023 {
5024 case eeGLEEOK:
5025 {
5026 Z_scripterrlog("Replacing a gleeok.\n");
5027 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
5028 hp = -999;
5029 tempenemy->hp = -999;
5030 break;
5031
5032 }
5033 default:
5034 hp = -1000; break;
5035 }
5036 ++game->guys[(currmap*MAPSCRSNORMAL)+currscr];
5037 return 1;
5038
5039 }
5040 case edSPLIT:
5041 {
5042 //int32_t ex = x; int32_t ey = y;
5043 //al_trace("edSplit dmisc3: %d\n", dmisc3);
5044 //al_trace("edSplit dmisc4: %d\n", dmisc4);
5045 /*
5046 if ( txsx > 1 )
5047 {
5048 ex += ( txsz-1 ) * 8; //from its middle
5049 }
5050 if ( tysx > 1 )
5051 {
5052 ey += ( tysz-1 ) * 8; //from its middle
5053 }
5054 */
5055 for ( int32_t q = 0; q < dmisc4; q++ )
5056 {
5057
5058 //addenemy((x+(txsz*16)/2),(y+(tysz*16)/2),dmisc3+0x1000,-15);
5059 addenemy(
5060 //ex,ey,
5061 x,y,
5062 dmisc3+0x1000,-15);
5063 //addenemy(ex,ey,dmisc3,0);
5064
5065 }
5066 item_set = 0; //Do not make a drop.
5067 hp = -1000;
5068 return -1;
5069
5070 }
5071 case edSUMMON:
5072 {
5073
5074
5075 //al_trace("edSplit dmisc3: %d\n", dmisc3);
5076 //al_trace("edSplit dmisc4: %d\n", dmisc4);
5077 int32_t summon_count = (zc_oldrand()%dmisc4)+1;
5078 for ( int32_t q = 0; q < summon_count; q++ )
5079 {
5080 int32_t x2=16*((zc_oldrand()%12)+2);
5081 int32_t y2=16*((zc_oldrand()%7)+2);
5082 addenemy(
5083 //(x+(txsz*16)/2),(y+(tysz*16)/2)
5084 x2,y2,
5085 dmisc3+0x1000,-15);
5086 //addenemy(ex,ey,dmisc3,0);
5087
5088 }
5089 sfx(get_bit(quest_rules,qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
5090 return -1;
5091
5092 }
5093
5094 case edEXPLODESMALL:
5095 {
5096 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
5097 Ewpns.add(ew);
5098 item_set = 0; //Should we make a drop?
5099 hp = -1000;
5100 return -1;
5101 }
5102
5103
5104 case edEXPLODEHARMLESS:
5105 {
5106 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
5107 Ewpns.add(ew);
5108 ew->hyofs = -32768;
5109 item_set = 0; //Should we make a drop?
5110 hp = -1000;
5111 return -1;
5112 }
5113
5114
5115 case edEXPLODELARGE:
5116 {
5117 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
5118 Ewpns.add(ew);
5119
5120 hp = -1000;
5121 return -1;
5122 }
5123
5124
5125 case edTRIGGERSECRETS:
5126 {
5127 hidden_entrance(0, true, false, -4);
5128 return -1;
5129 }
5130
5131 case edSTUNORCHINK:
5132
3/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 501 times.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
671 if (stunclk && get_bit(quest_rules, qr_NO_STUNLOCK))
5133 {
5134 sfx(WAV_CHINK,pan(int32_t(x)));
5135 return 1;
5136 }
5137
2/2
✓ Branch 0 taken 459 times.
✓ Branch 1 taken 106 times.
565 else if(*power <= 0)
5138 {
5139 //al_trace("defendNew() is at: %s\n", "returning edSTUNORCHINK");
5140 459 sfx(WAV_CHINK,pan(int32_t(x)));
5141 459 return 1;
5142 }
5143 [[fallthrough]];
5144
5145 case edSTUNORIGNORE:
5146
3/4
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 667 times.
✓ Branch 2 taken 156 times.
✗ Branch 3 not taken.
1054 if (stunclk && get_bit(quest_rules, qr_NO_STUNLOCK))
5147 {
5148 sfx(WAV_CHINK,pan(int32_t(x)));
5149 return 1;
5150 }
5151
2/2
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 231 times.
823 else if(*power <= 0)
5152 592 return 0;
5153 [[fallthrough]];
5154
5155 case edSTUNONLY:
5156
5/10
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 671 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 671 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 671 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 671 times.
✗ Branch 9 not taken.
671 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
5157 {
5158 //al_trace("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
5159 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
5160 return 1;
5161 }
5162
3/4
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 210 times.
✓ Branch 2 taken 461 times.
✗ Branch 3 not taken.
671 if (stunclk && get_bit(quest_rules, qr_NO_STUNLOCK))
5163 {
5164 sfx(WAV_CHINK,pan(int32_t(x)));
5165 return 1;
5166 }
5167 else
5168 {
5169 671 stunclk=160;
5170 671 sfx(WAV_EHIT,pan(int32_t(x)));
5171
5172 671 return 1;
5173 }
5174
5175 case edCHINKL1:
5176 if(*power >= 1*game->get_hero_dmgmult()) break;
5177 [[fallthrough]];
5178 case edCHINKL2:
5179
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(*power >= 2*game->get_hero_dmgmult()) break;
5180 [[fallthrough]];
5181 case edCHINKL4:
5182
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 19 times.
62 if(*power >= 4*game->get_hero_dmgmult()) break;
5183 [[fallthrough]];
5184 case edCHINKL6:
5185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(*power >= 6*game->get_hero_dmgmult()) break;
5186 [[fallthrough]];
5187 case edCHINKL8:
5188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(*power >= 8*game->get_hero_dmgmult()) break;
5189 [[fallthrough]];
5190 case edCHINKL10:
5191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(*power >= 10*game->get_hero_dmgmult()) break;
5192 [[fallthrough]];
5193 case edCHINK:
5194 //al_trace("defendNew() is at: %s\n", "returning edCHINK");
5195 72 sfx(WAV_CHINK,pan(int32_t(x)));
5196 72 return 1;
5197
5198 case edIGNOREL1:
5199 if(*power > 0) break;
5200 [[fallthrough]];
5201
5202 case edIGNORE:
5203 5454 return 0;
5204
5205 case ed1HKO:
5206 115 *power = hp;
5207 115 return -2;
5208
5209 case ed2x:
5210 {
5211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 *power = zc_max(1,*power*2);
5212 //int32_t pow = *power;
5213 //*power = vbound((pow*2),0,214747);
5214 71 return -1;
5215 }
5216 case ed3x:
5217 {
5218 *power = zc_max(1,*power*3);
5219 //int32_t pow = *power;
5220 //*power = vbound((pow*3),0,214747);
5221 return -1;
5222 }
5223
5224 case ed4x:
5225 {
5226 *power = zc_max(1,*power*4);
5227 //int32_t pow = *power;
5228 //*power = vbound((pow*4),0,214747);
5229 return -1;
5230 }
5231
5232
5233 case edHEAL:
5234 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
5235 //int32_t pow = *power;
5236 //*power = vbound((pow*-1),0,214747);
5237 //break;
5238 *power = zc_min(0,*power*-1);
5239 return -1;
5240 }
5241 /*
5242 case edLEVELDAMAGE:
5243 {
5244 int32_t pow = *power;
5245 int32_t lvl = *level;
5246 *power = vbound((pow*lvl),0,214747);
5247 break;
5248 }
5249 case edLEVELREDUCTION:
5250 {
5251 int32_t pow = *power;
5252 int32_t lvl = *level;
5253 *power = vbound((pow/lvl),0,214747);
5254 break;
5255 }
5256 */
5257
5258 case edQUARTDAMAGE:
5259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 *power = zc_max(1,*power/2);
5260
5261 [[fallthrough]];
5262 case edHALFDAMAGE:
5263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 *power = zc_max(1,*power/2);
5264 125 break;
5265
5266 case edSWITCH:
5267 {
5268 if(Hero.switchhookclk) return 0; //Already switching!
5269 switch(family)
5270 {
5271 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
5272 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
5273 return 0;
5274 }
5275 hooked_combopos = -1;
5276 hooked_layerbits = 0;
5277 switching_object = this;
5278 switch_hooked = true;
5279 Hero.doSwitchHook(game->get_switchhookstyle());
5280 if(QMisc.miscsfx[sfxSWITCHED])
5281 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
5282 return 1;
5283 }
5284
5285 case 0:
5286 {
5287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31185 times.
31185 if(edef == edefSwitchHook)
5288 return -1;
5289
3/6
✓ Branch 0 taken 9046 times.
✓ Branch 1 taken 22139 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9046 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31185 if (stunclk && get_bit(quest_rules, qr_NO_STUNLOCK) && *power == 0)
5290 {
5291 sfx(WAV_CHINK,pan(int32_t(x)));
5292 return 1;
5293 }
5294
5295 }
5296 31185 }
5297
5298 31374 return -1;
5299 41565 }
5300
5301 41565 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
5302 {
5303 41565 std::vector<int32_t> &ev = FFCore.eventData;
5304 41565 ev.clear();
5305 41565 ev.push_back(*power*10000);
5306 41565 ev.push_back(edef*10000);
5307 41565 ev.push_back(unblockable*10000);
5308 41565 ev.push_back(wpnId*10000);
5309 41565 ev.push_back(0);
5310 41565 ev.push_back(getUID());
5311
1/2
✓ Branch 0 taken 41565 times.
✗ Branch 1 not taken.
41565 ev.push_back(w?w->getUID():0);
5312
5313 41565 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
5314 41565 *power = ev[0]/10000;
5315 41565 edef = ev[1]/10000;
5316 41565 unblockable = byte(ev[2]/10000);
5317 41565 wpnId = ev[3] / 10000;
5318 41565 bool nullify = ev[4]!=0;
5319 41565 ev.clear();
5320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41565 times.
41565 if(nullify) return 0;
5321
5322 41565 int32_t ret = defendNew(wpnId, power, edef, unblockable);
5323
2/2
✓ Branch 0 taken 10403 times.
✓ Branch 1 taken 31162 times.
41565 if(ret != -1) return ret;
5324 31162 ev.push_back(*power*10000);
5325 31162 ev.push_back(edef*10000);
5326 31162 ev.push_back(unblockable*10000);
5327 31162 ev.push_back(wpnId*10000);
5328 31162 ev.push_back(0);
5329 31162 ev.push_back(getUID());
5330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31162 times.
31162 ev.push_back(w?w->getUID():0);
5331
5332 31162 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
5333 31162 *power = ev[0]/10000;
5334 31162 nullify = ev[4]!=0;
5335 31162 ev.clear();
5336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31162 times.
31162 if(nullify) return 0;
5337 31162 return -1;
5338 41565 }
5339
5340 30384 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w)
5341 {
5342 30384 int32_t wid = getWeaponID(w);
5343
5344 30384 int32_t edef = resolveEnemyDefence(w);
5345
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 29721 times.
30384 if(QHeader.zelda_version > 0x250)
5346 663 return defendNewInt(wid, power, edef, w->unblockable, w);
5347
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 29721 times.
✗ Branch 2 not taken.
29721 switch(wid)
5348 {
5349 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
5350 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
5351 return defend(wpnId, power, edefSCRIPT);
5352
5353 case wWhistle:
5354 return -1;
5355
5356 default:
5357 29721 return defendNewInt(wid, power, edef, w->unblockable, w);
5358 }
5359 30384 }
5360
5361
5362 // Check defenses without actually acting on them.
5363 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
5364 {
5365 switch(defense[edef])
5366 {
5367 case edSTUNONLY:
5368 return false;
5369 case edSTUNORCHINK:
5370 case edCHINK:
5371 return unblockable&WPNUNB_BLOCK;
5372 case edSTUNORIGNORE:
5373 case edIGNORE:
5374 return unblockable&WPNUNB_IGNR;
5375
5376 case edIGNOREL1:
5377 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
5378 case edCHINKL1:
5379 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
5380
5381 case edCHINKL2:
5382 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
5383
5384 case edCHINKL4:
5385 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
5386
5387 case edCHINKL6:
5388 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
5389
5390 case edCHINKL8:
5391 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
5392 }
5393
5394 return true;
5395 }
5396
5397 // Do we do damage?
5398 // 0: takehit returns 0
5399 // 1: takehit returns 1
5400 // -1: do damage
5401 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
5402 {
5403 if(shieldCanBlock)
5404 {
5405 switch(defense[edef])
5406 {
5407 case edIGNORE:
5408 return 0;
5409 case edIGNOREL1:
5410 case edSTUNORIGNORE:
5411 if(*power <= 0)
5412 return 0;
5413 }
5414
5415 sfx(WAV_CHINK,pan(int32_t(x)));
5416 return 1;
5417 }
5418
5419 switch(defense[edef])
5420 {
5421 case edSTUNORCHINK:
5422 if(*power <= 0)
5423 {
5424 sfx(WAV_CHINK,pan(int32_t(x)));
5425 return 1;
5426 }
5427
5428 [[fallthrough]];
5429 case edSTUNORIGNORE:
5430 if(*power <= 0)
5431 return 0;
5432
5433 [[fallthrough]];
5434 case edSTUNONLY:
5435 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
5436 return 1;
5437
5438 stunclk=160;
5439 sfx(WAV_EHIT,pan(int32_t(x)));
5440 return 1;
5441
5442 case edFREEZE:
5443 frozenclock=-1;
5444 //sfx(WAV_FREEZE,pan(int32_t(x)));
5445 return 1;
5446
5447 case edCHINKL1:
5448 if(*power >= 1*game->get_hero_dmgmult()) break;
5449 [[fallthrough]];
5450 case edCHINKL2:
5451 if(*power >= 2*game->get_hero_dmgmult()) break;
5452 [[fallthrough]];
5453 case edCHINKL4:
5454 if(*power >= 4*game->get_hero_dmgmult()) break;
5455 [[fallthrough]];
5456 case edCHINKL6:
5457 if(*power >= 6*game->get_hero_dmgmult()) break;
5458 [[fallthrough]];
5459 case edCHINKL8:
5460 if(*power >= 8*game->get_hero_dmgmult()) break;
5461 [[fallthrough]];
5462 case edCHINKL10:
5463 if(*power >= 10*game->get_hero_dmgmult()) break;
5464 [[fallthrough]];
5465 case edCHINK:
5466 sfx(WAV_CHINK,pan(int32_t(x)));
5467 return 1;
5468 case edTRIGGERSECRETS:
5469 hidden_entrance(0, true, false, -4);
5470 break;
5471
5472 case edIGNOREL1:
5473 if(*power > 0) break;
5474 [[fallthrough]];
5475 case edIGNORE:
5476 return 0;
5477
5478 case ed1HKO:
5479 *power = hp;
5480 return -2;
5481
5482 case ed2x:
5483 {
5484 *power = zc_max(1,*power*2);
5485 //int32_t pow = *power;
5486 //*power = vbound((pow*2),0,214747);
5487 return -1;
5488 }
5489 case ed3x:
5490 {
5491 *power = zc_max(1,*power*3);
5492 //int32_t pow = *power;
5493 //*power = vbound((pow*3),0,214747);
5494 return -1;
5495 }
5496
5497 case ed4x:
5498 {
5499 *power = zc_max(1,*power*4);
5500 //int32_t pow = *power;
5501 //*power = vbound((pow*4),0,214747);
5502 return -1;
5503 }
5504
5505
5506 case edHEAL:
5507 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
5508 //int32_t pow = *power;
5509 //*power = vbound((pow*-1),0,214747);
5510 //break;
5511 *power = zc_min(0,*power*-1);
5512 return -1;
5513 }
5514 /*
5515 case edLEVELDAMAGE:
5516 {
5517 int32_t pow = *power;
5518 int32_t lvl = *level;
5519 *power = vbound((pow*lvl),0,214747);
5520 break;
5521 }
5522 case edLEVELREDUCTION:
5523 {
5524 int32_t pow = *power;
5525 int32_t lvl = *level;
5526 *power = vbound((pow/lvl),0,214747);
5527 break;
5528 }
5529 */
5530
5531
5532 case edQUARTDAMAGE:
5533 *power = zc_max(1,*power/2);
5534
5535 [[fallthrough]];
5536 case edHALFDAMAGE:
5537 *power = zc_max(1,*power/2);
5538 break;
5539 }
5540
5541 return -1;
5542 }
5543
5544 // Defend against a particular item class.
5545 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
5546 {
5547 int32_t def=-1;
5548
5549 switch(wpnId)
5550 {
5551 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
5552 case wBrang:
5553 def = defend(wpnId, power, edefBRANG);
5554 break;
5555
5556 case wHookshot:
5557 def = defend(wpnId, power, edefHOOKSHOT);
5558 break;
5559
5560 // Anyway...
5561 case wBomb:
5562 def = defend(wpnId, power, edefBOMB);
5563 break;
5564
5565 case wSBomb:
5566 def = defend(wpnId, power, edefSBOMB);
5567 break;
5568
5569 case wArrow:
5570 def = defend(wpnId, power, edefARROW);
5571 break;
5572
5573 case wFire:
5574 def = defend(wpnId, power, edefFIRE);
5575 break;
5576
5577 case wWand:
5578 def = defend(wpnId, power, edefWAND);
5579 break;
5580
5581 case wMagic:
5582 def = defend(wpnId, power, edefMAGIC);
5583 break;
5584
5585 case wHammer:
5586 def = defend(wpnId, power, edefHAMMER);
5587 break;
5588
5589 case wSword:
5590 def = defend(wpnId, power, edefSWORD);
5591 break;
5592
5593 case wBeam:
5594 def = defend(wpnId, power, edefBEAM);
5595 break;
5596
5597 case wRefBeam:
5598 def = defend(wpnId, power, edefREFBEAM);
5599 break;
5600
5601 case wRefMagic:
5602 def = defend(wpnId, power, edefREFMAGIC);
5603 break;
5604
5605 case wRefFireball:
5606 def = defend(wpnId, power, edefREFBALL);
5607 break;
5608
5609 case wRefRock:
5610 def = defend(wpnId, power, edefREFROCK);
5611 break;
5612
5613 case wStomp:
5614 def = defend(wpnId, power, edefSTOMP);
5615 break;
5616
5617 case wCByrna:
5618 def = defend(wpnId, power, edefBYRNA);
5619 break;
5620
5621 case wScript1:
5622 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
5623 else def = defend(wpnId, power, edefSCRIPT);
5624 break;
5625
5626 case wScript2:
5627 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
5628 else def = defend(wpnId, power, edefSCRIPT);
5629 break;
5630
5631 case wScript3:
5632 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
5633 else def = defend(wpnId, power, edefSCRIPT);
5634 break;
5635
5636 case wScript4:
5637 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
5638 else def = defend(wpnId, power, edefSCRIPT);
5639 break;
5640
5641 case wScript5:
5642 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
5643 else def = defend(wpnId, power, edefSCRIPT);
5644 break;
5645
5646 case wScript6:
5647 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
5648 else def = defend(wpnId, power, edefSCRIPT);
5649 break;
5650
5651 case wScript7:
5652 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
5653 else def = defend(wpnId, power, edefSCRIPT);
5654 break;
5655
5656 case wScript8:
5657 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
5658 else def = defend(wpnId, power, edefSCRIPT);
5659 break;
5660
5661 case wScript9:
5662 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
5663 else def = defend(wpnId, power, edefSCRIPT);
5664 break;
5665
5666 case wScript10:
5667 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
5668 else def = defend(wpnId, power, edefSCRIPT);
5669 break;
5670
5671 case wWhistle:
5672 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
5673 else break;
5674 break;
5675
5676
5677 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
5678 //Probably best to do this from the qest file, loading the values of Script(generic) into each
5679 //of the ten if the quest version is lower than N.
5680 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
5681 //such as bool UseSeparatedScriptDefences. hah.
5682 default:
5683 //if(wpnId>=wScript1 && wpnId<=wScript10)
5684 // {
5685 // def = defend(wpnId, power, edefSCRIPT);
5686 // }
5687 // }
5688
5689 break;
5690 }
5691
5692 return def;
5693 }
5694
5695 // take damage or ignore it
5696 // -1: damage (if any) dealt
5697 // 1: blocked
5698 // 0: weapon passes through unhindered
5699 104230 int32_t enemy::takehit(weapon *w)
5700 {
5701
2/4
✓ Branch 0 taken 104230 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104230 times.
104230 if(fallclk||drownclk) return 0;
5702 104230 int32_t wpnId = w->id;
5703 //al_trace("takehit() wpnId is %d\n",wpnId);
5704 //if ( wpnId == wWhistle ) al_trace("Whistle weapon in %s\n", "takehit");
5705 104230 int32_t power = w->power;
5706 104230 int32_t wpnx = w->x;
5707 104230 int32_t wpny = w->y;
5708 104230 int32_t enemyHitWeapon = w->parentitem;
5709 int32_t wpnDir;
5710 104230 int32_t parent_item = w->parentitem;
5711
5712 //if ( parent_item > -1 )
5713 //{
5714 // if ( itemsbuf[parent_item].useweapon > 0 /*&& wpnId != wWhistle*/ )
5715 // {
5716 // wpnId = itemsbuf[parent_item].useweapon;
5717 // }
5718
5719 //}
5720 //if ( parent_item == -1 && w->ScriptGenerated )
5721 //{
5722 // if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
5723 // {
5724 // wpnId = w->useweapon;
5725 // }
5726
5727 //}
5728 //al_trace("takehit wpnId is: %d\n",wpnId);
5729
5730 //Shoud be set from idata from the weapon::weaon constructor. -Z
5731
1/2
✓ Branch 0 taken 104230 times.
✗ Branch 1 not taken.
104230 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
5732 {
5733 wpnId = w->useweapon;
5734 }
5735
5736 //al_trace("takehit() useweapon is %d\n",itemsbuf[parent_item].useweapon);
5737
5738 //Weapon Editor -Z
5739
5740
5741 // If it's a boomerang that just bounced, use the opposite direction;
5742 // otherwise, it might bypass a shield. This probably won't handle
5743 // every case correctly, but it's better than having shields simply
5744 // not work against boomerangs.
5745
8/8
✓ Branch 0 taken 11190 times.
✓ Branch 1 taken 93040 times.
✓ Branch 2 taken 7536 times.
✓ Branch 3 taken 3654 times.
✓ Branch 4 taken 7245 times.
✓ Branch 5 taken 291 times.
✓ Branch 6 taken 1559 times.
✓ Branch 7 taken 5686 times.
104230 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
5746 5686 wpnDir = oppositeDir[w->dir];
5747 else
5748 98544 wpnDir = w->dir;
5749
5750
5/8
✓ Branch 0 taken 104230 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104230 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 104230 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 623 times.
✓ Branch 7 taken 103607 times.
104230 if(dying || clk<0 || hclk>0 || superman)
5751 {
5752 623 return 0;
5753 }
5754
5755 //Prevent boomerang from writing to hitby[] for more than one frame.
5756 //This also prevents stunlock.
5757 //if ( stunclk > 0 ) return 0;
5758 //this needs a rule for boomerangs that cannot stunlock!
5759 //further, bouncing weapons should probably SFX_CHINK and bounce here.
5760 //sigh.
5761
5762 103607 int32_t ret = -1;
5763
5764 // This obscure quest rule...
5765
5/6
✓ Branch 0 taken 71237 times.
✓ Branch 1 taken 32370 times.
✓ Branch 2 taken 71132 times.
✓ Branch 3 taken 105 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 71132 times.
103607 if(get_bit(quest_rules,qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
5766 {
5767 double _MSVC2022_tmp1, _MSVC2022_tmp2;
5768 105 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
5769 105 wpnDir=zc_oldrand()&3;
5770
5771
4/4
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 51 times.
105 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
5772 {
5773 51 wpnDir=down;
5774 51 }
5775
4/4
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 20 times.
54 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
5776 {
5777 20 wpnDir=right;
5778 20 }
5779
4/4
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 5 times.
34 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
5780 {
5781 5 wpnDir=up;
5782 5 }
5783 else
5784 {
5785 29 wpnDir=left;
5786 }
5787 105 }
5788
5789 103607 int32_t xdir = dir;
5790 103607 shieldCanBlock=false;
5791
5792 //if (family==eeFLOAT && flags&(inv_front|inv_back_inv_left|inv_right)) xdir=down;
5793
2/4
✓ Branch 0 taken 103607 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 103607 times.
104360 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
5794
9/10
✓ Branch 0 taken 6362 times.
✓ Branch 1 taken 6362 times.
✓ Branch 2 taken 8026 times.
✓ Branch 3 taken 101943 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 101943 times.
✓ Branch 6 taken 941 times.
✓ Branch 7 taken 101002 times.
✓ Branch 8 taken 753 times.
✓ Branch 9 taken 100249 times.
103607 || ((flags&inv_front && wpnDir==(xdir^down)) || (flags&inv_back && wpnDir==(xdir^up)) || (flags&inv_left && wpnDir==(xdir^left)) || (flags&inv_right && wpnDir==(xdir^right))))
5795 )
5796 // The hammer should already be dealt with by subclasses (Walker etc.)
5797 {
5798
9/9
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 2573 times.
✓ Branch 4 taken 136 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 263 times.
16082 switch(wpnId)
5799 {
5800 // Weapons which shields protect against
5801 case wSword:
5802 case wWand:
5803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2573 times.
2573 if(Hero.getCharging()>0)
5804 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
5805
5806 [[fallthrough]];
5807 case wHookshot:
5808 case wHSHandle:
5809 case wBrang:
5810 2594 shieldCanBlock=true;
5811 2730 break;
5812
5813 case wBeam:
5814 case wRefBeam:
5815 // Mirror shielded enemies!
5816 #if 0
5817 if(false /*flags2&guy_mirror*/ && !get_bit(quest_rules,qr_SWORDMIRROR))
5818 {
5819 if(wpnId>wEnemyWeapons)
5820 return 0;
5821
5822 sfx(WAV_CHINK,pan(int32_t(x)));
5823 return 1;
5824 }
5825
5826 #endif
5827
5828 [[fallthrough]];
5829 case wRefRock:
5830 case wRefFireball:
5831 case wMagic:
5832 #if 0
5833 if(false /*flags2&guy_mirror*/ && (wpnId!=wRefRock || get_bit(quest_rules,qr_REFLECTROCKS)))
5834 {
5835 sfx(WAV_CHINK,pan(int32_t(x)));
5836 return 3;
5837 }
5838
5839 #endif
5840
5841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if(wpnId>wEnemyWeapons)
5842 return 0;
5843
5844 [[fallthrough]];
5845 default:
5846 141 shieldCanBlock=true;
5847 141 break;
5848
5849 // Bombs
5850 case wSBomb:
5851 case wBomb:
5852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (!get_bit(quest_rules,qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
5853 else if (!get_bit(quest_rules,qr_BOMBSPIERCESHIELD))
5854 {
5855 sfx(WAV_CHINK,pan(int32_t(x)));
5856 return 0;
5857 }
5858 else break;
5859
5860 // Weapons which ignore shields
5861 case wWhistle:
5862 case wHammer:
5863 1 break;
5864
5865 // Weapons which shouldn't be removed by shields
5866 case wLitBomb:
5867 case wLitSBomb:
5868 case wWind:
5869 case wPhantom:
5870 case wSSparkle:
5871 case wBait:
5872 358 return 0;
5873
5874 [[fallthrough]];
5875 case wFire:
5876 #if 0
5877 if(false /*flags2&guy_mirror*/)
5878 {
5879 sfx(WAV_CHINK,pan(int32_t(x)));
5880 return 1;
5881 }
5882
5883 #endif
5884 ;
5885 263 }
5886 2999 }
5887
5888
4/8
✓ Branch 0 taken 61732 times.
✓ Branch 1 taken 30211 times.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11181 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
103248 switch(wpnId)
5889 {
5890 case wWhistle: //No longer completely ignore whistle weapons! -Z
5891 {
5892
5893
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
124 if ( ((itemsbuf[parent_item].flags & ITEM_FLAG2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
5894 {
5895 //al_trace("Whistle weapon in %s\n", "takehit flag == 0");
5896 124 return 0; break;
5897 }
5898 else
5899 {
5900 w->power = power = itemsbuf[parent_item].misc5;
5901
5902 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, w);
5903
5904 if(def <= 0)
5905 {
5906 if ( def == -2 ) hp -= hp;
5907 else hp -= power;
5908 return def;
5909 }
5910 break;
5911 }
5912 break;
5913 }
5914
5915 case wPhantom:
5916 return 0;
5917
5918 case wLitBomb:
5919 case wLitSBomb:
5920 case wBait:
5921 case wWind:
5922 case wSSparkle:
5923 61732 return 0;
5924
5925 case wFSparkle:
5926
5927 // Only take sparkle damage if the sparkle's parent item is not
5928 // defended against.
5929 if(enemyHitWeapon > -1)
5930 {
5931 int32_t p = 0;
5932 int32_t f = itemsbuf[enemyHitWeapon].family;
5933
5934 switch(f)
5935 {
5936 case itype_arrow:
5937 if(!candamage(p, edefARROW, w->unblockable)) return 0;
5938
5939 break;
5940
5941 case itype_cbyrna:
5942 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
5943
5944 break;
5945
5946 case itype_brang:
5947 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
5948
5949 break;
5950
5951 default:
5952 return 0;
5953 }
5954 }
5955
5956 wpnId = wSword;
5957 power = game->get_hero_dmgmult()>>1;
5958 goto fsparkle;
5959 break;
5960
5961 case wBrang:
5962 {
5963 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
5964 11181 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, w);
5965 //preventing stunlock might be best, here. -Z
5966
2/2
✓ Branch 0 taken 2099 times.
✓ Branch 1 taken 9082 times.
11181 if(def >= 0) return def;
5967
5968 // Not hurt by 0-damage weapons
5969
2/2
✓ Branch 0 taken 1412 times.
✓ Branch 1 taken 7670 times.
9082 if(!(flags & guy_bhit))
5970 {
5971 7670 stunclk=160;
5972
5973
3/4
✓ Branch 0 taken 7670 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✓ Branch 3 taken 7500 times.
7670 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
5974 {
5975
1/2
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
170 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
5976 170 goto hitclock;
5977 }
5978
5979 7500 break;
5980 }
5981
5982
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 1354 times.
1412 if(!power)
5983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1354 times.
1354 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_brang))*game->get_hero_dmgmult();
5984 else
5985 58 hp-=power;
5986
5987 1412 goto hitclock;
5988 }
5989
5990 case wHookshot:
5991 {
5992 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
5993 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, w);
5994
5995 if(def >= 0) return def;
5996
5997 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
5998 if(swgrab || !(flags & guy_bhit))
5999 {
6000 if(!swgrab)
6001 stunclk=160;
6002
6003 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
6004 {
6005 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
6006 goto hitclock;
6007 }
6008
6009 break;
6010 }
6011
6012 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_hookshot))*game->get_hero_dmgmult();
6013 else
6014 hp-=power;
6015
6016 goto hitclock;
6017 }
6018 break;
6019
6020 case wHSHandle:
6021 {
6022 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & ITEM_FLAG1)
6023 return 0;
6024
6025 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
6026 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
6027
6028 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
6029 if(!(family==eePEAHAT || family==eeAQUA || family==eeMANHAN || (family==eeWIZZ && !ignorehookshot)
6030 || (family==eeWALK && dmisc9==e9tPOLSVOICE) || (family==eeWALK && flags&(inv_back|inv_front|inv_left|inv_right))))
6031 return 0;
6032
6033 power = game->get_hero_dmgmult();
6034 }
6035
6036 fsparkle:
6037
6038 [[fallthrough]];
6039 default:
6040 // Work out the defenses!
6041 {
6042 30211 int32_t def = defenditemclassNew(wpnId, &power, w);
6043
6044
2/2
✓ Branch 0 taken 8088 times.
✓ Branch 1 taken 22123 times.
30211 if(def >= 0)
6045 8088 return def;
6046
2/2
✓ Branch 0 taken 22040 times.
✓ Branch 1 taken 83 times.
22123 else if(def == -2)
6047 {
6048 83 ret = 0;
6049 83 }
6050 }
6051
6052
2/2
✓ Branch 0 taken 22121 times.
✓ Branch 1 taken 2 times.
44246 if(!power)
6053 {
6054
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags & guy_bhit)
6055 2 hp-=1;
6056 else
6057 {
6058 // Don't make a long chain of 'stun' hits
6059 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
6060 return 1;
6061
6062
6063 if(!switch_hooked)
6064 stunclk=160;
6065 break;
6066 }
6067 2 }
6068 22121 else hp-=power;
6069
6070 hitclock:
6071 23706 hclk=33;
6072
6073 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
6074
2/2
✓ Branch 0 taken 11074 times.
✓ Branch 1 taken 12632 times.
23706 if((dir&2)==(w->dir&2))
6075 {
6076 12632 sclk=(w->dir<<8)+16;
6077 12632 }
6078 23706 }
6079
6080
5/6
✓ Branch 0 taken 22124 times.
✓ Branch 1 taken 9082 times.
✓ Branch 2 taken 1048 times.
✓ Branch 3 taken 30158 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1048 times.
31206 if(((wpnId==wBrang) || (get_bit(quest_rules,qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
6081 {
6082 1048 fading=fade_blue_poof;
6083 1048 }
6084
6085
6086 /*
6087 if( hitsfx > 0 ) //user set hit sound.
6088 {
6089 if ( !dying ) //Don't play the hit sound when dying.
6090 sfx(hitsfx, pan(int32_t(x)));
6091 }
6092 else sfx(WAV_EHIT, pan(int32_t(x))); //Don't play this one if the user sets a custom sound!
6093 */
6094 /*
6095 if( hitsfx > 0 ) //A sound is set.
6096 {
6097 if ( !dying ) //Don't play the hit sound when dying.
6098 sfx(hitsfx, pan(int32_t(x)));
6099 }
6100 */
6101
5/6
✓ Branch 0 taken 30605 times.
✓ Branch 1 taken 601 times.
✓ Branch 2 taken 30605 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1328 times.
✓ Branch 5 taken 29277 times.
31206 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
6102 {
6103
1/2
✓ Branch 0 taken 1929 times.
✗ Branch 1 not taken.
1929 if( hitsfx > 0 ) //user-set hit sound.
6104 {
6105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1929 times.
1929 if (!dying) //don't play the hit sound on death! -Z
6106 1929 sfx(hitsfx, pan(int32_t(x)));
6107 1929 }
6108 else sfx(WAV_EHIT, pan(int32_t(x))); //Don't play the hardcoded sound if the user sets a custom one.
6109 1929 }
6110 else //2.50.2 or earlier
6111 {
6112 29277 sfx(WAV_EHIT, pan(int32_t(x)));
6113 29277 sfx(hitsfx, pan(int32_t(x)));
6114 }
6115
2/2
✓ Branch 0 taken 31204 times.
✓ Branch 1 taken 2 times.
31206 if(family==eeGUY)
6116 2 sfx(WAV_EDEAD, pan(int32_t(x)));
6117
6118 // Penetrating weapons
6119
4/4
✓ Branch 0 taken 31016 times.
✓ Branch 1 taken 190 times.
✓ Branch 2 taken 27821 times.
✓ Branch 3 taken 3385 times.
31206 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
6120 {
6121 3385 int32_t item=enemyHitWeapon;
6122
6123
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 3267 times.
3385 if(wpnId==wArrow)
6124 {
6125 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
6126
2/6
✓ Branch 0 taken 118 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 118 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
118 if(item>=0 && (itemsbuf[item].flags&ITEM_FLAG1) && (itemsbuf[parent_item].family == itype_arrow))
6127 return 0;
6128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118 times.
118 else if(get_bit(quest_rules,qr_ARROWS_ALWAYS_PENETRATE)) return 0;
6129 //if(item<0)
6130 else
6131 118 item=current_item_id(itype_arrow);
6132 118 }
6133
6134 else
6135 {
6136
6137 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
6138
2/6
✓ Branch 0 taken 3267 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3267 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3267 if(item>=0 && (itemsbuf[item].flags&ITEM_FLAG3) && (itemsbuf[parent_item].family == itype_sword))
6139 return 0;
6140
6141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3267 times.
3267 else if(get_bit(quest_rules,qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
6142 else
6143 //if(item<0)
6144 3267 item=current_item_id(itype_sword);
6145 }
6146 3385 }
6147
6148 31206 return ret;
6149 104230 }
6150
6151 13728703 bool enemy::dont_draw()
6152 {
6153
6/6
✓ Branch 0 taken 13714419 times.
✓ Branch 1 taken 14284 times.
✓ Branch 2 taken 13703972 times.
✓ Branch 3 taken 10447 times.
✓ Branch 4 taken 4797 times.
✓ Branch 5 taken 13709622 times.
13728703 if(fading==fade_invisible || (((flags2&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
6154 19081 return true;
6155
6156
2/2
✓ Branch 0 taken 147943 times.
✓ Branch 1 taken 13561679 times.
13709622 if(flags&guy_invisible)
6157 147943 return true;
6158
6159
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 13561247 times.
✓ Branch 2 taken 432 times.
✗ Branch 3 not taken.
13561679 if(flags&lens_only && !lensclk)
6160 return true;
6161
6162
3/8
✓ Branch 0 taken 789 times.
✓ Branch 1 taken 13560890 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 789 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
13561679 if(lensclk && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) &&
6163 !((flags&lens_only) && (get_bit(quest_rules,qr_LENSSEESENEMIES) || (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG5))))
6164 return true;
6165
6166 13561679 return false;
6167 13728703 }
6168
6169 #define DRAW_NORMAL 2
6170 #define DRAW_CLOAKED 1
6171 #define DRAW_INVIS 0
6172 // base drawing function to be used by all derived classes instead of
6173 // sprite::draw()
6174 13028914 void enemy::draw(BITMAP *dest)
6175 {
6176
6/6
✓ Branch 0 taken 12863884 times.
✓ Branch 1 taken 165030 times.
✓ Branch 2 taken 12842648 times.
✓ Branch 3 taken 21236 times.
✓ Branch 4 taken 77921 times.
✓ Branch 5 taken 12785963 times.
13028914 if(fading==fade_invisible || (((flags2&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
6177 242951 return;
6178
2/2
✓ Branch 0 taken 1091401 times.
✓ Branch 1 taken 11694562 times.
12785963 if(flags&guy_invisible)
6179 1091401 return;
6180
3/8
✓ Branch 0 taken 789 times.
✓ Branch 1 taken 11693773 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 789 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
11694562 if(lensclk && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) && !(flags&lens_only))
6181 return;
6182
6183 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
6184 // be cloaked if they have "invisible displays as cloaked" checked.
6185
6186 11694562 byte canSee = DRAW_NORMAL;
6187 //Enemy specific stuff
6188
1/2
✓ Branch 0 taken 11694562 times.
✗ Branch 1 not taken.
11694562 if ( editorflags & ENEMY_FLAG1 )
6189 {
6190 canSee = DRAW_INVIS;
6191 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
6192 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
6193 {
6194 if (game->item[dmisc13])
6195 {
6196 canSee = DRAW_NORMAL;
6197 }
6198 //else if ( lensclk && getlensid.flags SHOWINVIS )
6199 //{
6200 //
6201 //}
6202 //else
6203 //{
6204 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
6205 // //otherwisem invisible
6206 //}
6207 }
6208 }
6209 //Room specific
6210
2/2
✓ Branch 0 taken 11685593 times.
✓ Branch 1 taken 8969 times.
11694562 if (tmpscr->flags3&fINVISROOM)
6211 {
6212
4/6
✓ Branch 0 taken 8969 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3044 times.
✓ Branch 3 taken 5925 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3044 times.
12013 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
6213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3044 times.
3044 !((itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG5) && lensclk) && family!=eeGANON) canSee = DRAW_CLOAKED;
6214 8969 }
6215 //Lens check
6216
2/2
✓ Branch 0 taken 789 times.
✓ Branch 1 taken 11693773 times.
11694562 if (lensclk)
6217 {
6218
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 789 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
789 if((itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(flags&lens_only))
6219 {
6220 if (canSee == DRAW_NORMAL)
6221 {
6222 if (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) canSee = DRAW_CLOAKED;
6223 else canSee = DRAW_INVIS; //Should never happen cause dont_draw should catch this, but just in case.
6224 }
6225 }
6226
2/2
✓ Branch 0 taken 357 times.
✓ Branch 1 taken 432 times.
789 if(flags&lens_only)
6227 {
6228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 432 times.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
6229 432 }
6230 789 }
6231 else
6232 {
6233
2/2
✓ Branch 0 taken 11620357 times.
✓ Branch 1 taken 73416 times.
11693773 if(flags&lens_only)
6234 73416 canSee = DRAW_INVIS;
6235 }
6236
3/4
✓ Branch 0 taken 73416 times.
✓ Branch 1 taken 11621146 times.
✓ Branch 2 taken 73416 times.
✗ Branch 3 not taken.
11694562 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
6237
3/4
✓ Branch 0 taken 11618102 times.
✓ Branch 1 taken 76460 times.
✓ Branch 2 taken 11618102 times.
✗ Branch 3 not taken.
11694562 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
6238
6239
2/2
✓ Branch 0 taken 11621146 times.
✓ Branch 1 taken 73416 times.
11694562 if (canSee == DRAW_INVIS)
6240 73416 return;
6241
6242
2/4
✓ Branch 0 taken 11621146 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11621146 times.
11621146 if(fallclk||drownclk)
6243 {
6244 if (canSee == DRAW_CLOAKED)
6245 {
6246 sprite::drawcloaked(dest);
6247 }
6248 else if (canSee == DRAW_NORMAL)
6249 {
6250 sprite::draw(dest);
6251 }
6252 return;
6253 }
6254 11621146 int32_t cshold=cs;
6255
6256
2/2
✓ Branch 0 taken 277845 times.
✓ Branch 1 taken 11343301 times.
11621146 if(dying)
6257 {
6258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 277845 times.
277845 if(clk2>=19)
6259 {
6260 if(!(clk2&2))
6261 {
6262 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
6263 if (canSee == DRAW_CLOAKED)
6264 {
6265 sprite::drawcloaked(dest);
6266 }
6267 else if (canSee == DRAW_NORMAL)
6268 {
6269 sprite::draw(dest);
6270 }
6271 }
6272 return;
6273 }
6274
6275 277845 flip = 0;
6276 277845 tile = wpnsbuf[spr_death].tile;
6277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 277845 times.
277845 if ( do_animation )
6278 {
6279 277845 int32_t offs = 0;
6280
2/2
✓ Branch 0 taken 275318 times.
✓ Branch 1 taken 2527 times.
277845 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS))
6281 {
6282
2/2
✓ Branch 0 taken 2373 times.
✓ Branch 1 taken 154 times.
2527 if(clk2 > 2)
6283 {
6284 154 spr_death_anim_clk=0;
6285 154 clk2=1;
6286
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 151 times.
154 if(hp > -1000)
6287 151 death_sfx();
6288 154 }
6289
4/4
✓ Branch 0 taken 2468 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 2464 times.
2527 if(clk2==1 && spr_death_anim_clk>-1)
6290 {
6291 2464 ++clk2;
6292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2464 times.
2464 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
6293
1/2
✓ Branch 0 taken 2464 times.
✗ Branch 1 not taken.
2464 spr_death_anim_frm *= zc_max(1,txsz);
6294 2464 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
6295
2/2
✓ Branch 0 taken 2391 times.
✓ Branch 1 taken 73 times.
2464 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
6296
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2464 times.
✓ Branch 2 taken 2464 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 154 times.
✓ Branch 5 taken 2310 times.
2464 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
6297 {
6298 154 spr_death_anim_clk=-1;
6299 154 clk2=1;
6300 154 }
6301 2464 }
6302 2527 tile += spr_death_anim_frm;
6303 2527 }
6304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275318 times.
275318 else if(BSZ)
6305 {
6306 offs = zc_min((15-clk2)/3,4);
6307 }
6308
4/4
✓ Branch 0 taken 183437 times.
✓ Branch 1 taken 91881 times.
✓ Branch 2 taken 91737 times.
✓ Branch 3 taken 91700 times.
275318 else if(clk2>6 && clk2<=12)
6309 {
6310 91700 offs = 1;
6311 91700 }
6312
6313
2/2
✓ Branch 0 taken 186145 times.
✓ Branch 1 taken 91700 times.
277845 if(offs)
6314 {
6315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91700 times.
91700 offs *= zc_max(1,txsz);
6316 91700 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
6317
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 91688 times.
91700 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
6318 91700 }
6319 277845 tile += offs;
6320 277845 }
6321
6322
5/6
✓ Branch 0 taken 275318 times.
✓ Branch 1 taken 2527 times.
✓ Branch 2 taken 275318 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 40712 times.
✓ Branch 5 taken 234606 times.
277845 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
6323 43239 cs = wpnsbuf[spr_death].csets&15;
6324 else
6325 234606 cs = (((clk2+5)>>1)&3)+6;
6326 277845 }
6327
3/4
✓ Branch 0 taken 407972 times.
✓ Branch 1 taken 10935329 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 407972 times.
11343301 else if(hclk>0 && getCanFlicker())
6328 {
6329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 407972 times.
407972 if(family==eeGANON)
6330 cs=(((hclk-1)>>1)&3)+6;
6331
4/4
✓ Branch 0 taken 379144 times.
✓ Branch 1 taken 28828 times.
✓ Branch 2 taken 146579 times.
✓ Branch 3 taken 232565 times.
407972 else if(hclk<33 && !get_bit(quest_rules,qr_ENEMIESFLICKER))
6332 232565 cs=(((hclk-1)>>1)&3)+6;
6333 407972 }
6334 //draw every other frame for flickering enemies
6335
8/10
✓ Branch 0 taken 5809349 times.
✓ Branch 1 taken 5811797 times.
✓ Branch 2 taken 5809349 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 337658 times.
✓ Branch 5 taken 5471691 times.
✓ Branch 6 taken 108920 times.
✓ Branch 7 taken 228738 times.
✓ Branch 8 taken 108920 times.
✗ Branch 9 not taken.
11621146 if((frame&1)==1 || !(family !=eeGANON && hclk>0 && get_bit(quest_rules,qr_ENEMIESFLICKER) && getCanFlicker()))
6336 {
6337
2/2
✓ Branch 0 taken 2873 times.
✓ Branch 1 taken 11509353 times.
11512226 if (canSee == DRAW_CLOAKED)
6338 {
6339 2873 sprite::drawcloaked(dest);
6340 2873 }
6341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11509353 times.
11509353 else if (canSee == DRAW_NORMAL)
6342 {
6343
1/2
✓ Branch 0 taken 11509353 times.
✗ Branch 1 not taken.
11509353 if ( frozenclock < 0 )
6344 {
6345 if ( frozentile > 0 ) tile = frozentile;
6346 loadpalset(csBOSS,frozencset);
6347 }
6348 11509353 sprite::draw(dest);
6349 11509353 }
6350 11512226 }
6351 11621146 cs=cshold;
6352 13028914 }
6353
6354 //old zc bosses
6355 11747266 void enemy::drawzcboss(BITMAP *dest)
6356 {
6357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11747266 times.
11747266 if(dont_draw())
6358 return;
6359
6360 11747266 int32_t cshold=cs;
6361
6362
2/2
✓ Branch 0 taken 250398 times.
✓ Branch 1 taken 11496868 times.
11747266 if(dying)
6363 {
6364
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 247878 times.
250398 if(clk2>=19)
6365 {
6366
2/2
✓ Branch 0 taken 1260 times.
✓ Branch 1 taken 1260 times.
2520 if(!(clk2&2))
6367 1260 sprite::drawzcboss(dest);
6368
6369 2520 return;
6370 }
6371
6372 247878 flip = 0;
6373 247878 tile = wpnsbuf[spr_death].tile;
6374
6375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247878 times.
247878 if ( do_animation )
6376 {
6377
1/2
✓ Branch 0 taken 247878 times.
✗ Branch 1 not taken.
247878 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS))
6378 {
6379 if(clk2 > 2)
6380 {
6381 spr_death_anim_clk=0;
6382 clk2=1;
6383 if(hp > -1000)
6384 death_sfx();
6385 }
6386 if(clk2==1 && spr_death_anim_clk>-1)
6387 {
6388 ++clk2;
6389 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
6390 spr_death_anim_frm *= zc_max(1,txsz);
6391 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
6392 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
6393 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
6394 {
6395 spr_death_anim_clk=-1;
6396 clk2=1;
6397 }
6398 }
6399 tile += spr_death_anim_frm;
6400 }
6401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247878 times.
247878 else if(BSZ)
6402 tile += zc_min((15-clk2)/3,4);
6403
4/4
✓ Branch 0 taken 165098 times.
✓ Branch 1 taken 82780 times.
✓ Branch 2 taken 82500 times.
✓ Branch 3 taken 82598 times.
247878 else if(clk2>6 && clk2<=12)
6404 82598 ++tile;
6405 247878 }
6406
6407
4/6
✓ Branch 0 taken 247878 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 247878 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 38354 times.
✓ Branch 5 taken 209524 times.
247878 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
6408 38354 cs = wpnsbuf[spr_death].csets&15;
6409 else
6410 209524 cs = (((clk2+5)>>1)&3)+6;
6411 247878 }
6412
2/2
✓ Branch 0 taken 11115805 times.
✓ Branch 1 taken 381063 times.
11496868 else if(hclk>0)
6413 {
6414
2/2
✓ Branch 0 taken 1296 times.
✓ Branch 1 taken 379767 times.
381063 if(family==eeGANON)
6415 1296 cs=(((hclk-1)>>1)&3)+6;
6416
4/4
✓ Branch 0 taken 355194 times.
✓ Branch 1 taken 24573 times.
✓ Branch 2 taken 87333 times.
✓ Branch 3 taken 267861 times.
379767 else if(hclk<33 && !get_bit(quest_rules,qr_ENEMIESFLICKER))
6417 267861 cs=(((hclk-1)>>1)&3)+6;
6418 381063 }
6419
6420
2/4
✓ Branch 0 taken 5711 times.
✓ Branch 1 taken 11739035 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11744746 if((tmpscr->flags3&fINVISROOM) &&
6421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5711 times.
5711 !(current_item(itype_amulet)) &&
6422 !(get_bit(quest_rules,qr_LENSSEESENEMIES) &&
6423 lensclk) && family!=eeGANON)
6424 {
6425 sprite::drawcloaked(dest);
6426 }
6427 else
6428 {
6429
6/6
✓ Branch 0 taken 11734262 times.
✓ Branch 1 taken 10484 times.
✓ Branch 2 taken 615117 times.
✓ Branch 3 taken 11119145 times.
✓ Branch 4 taken 493254 times.
✓ Branch 5 taken 121863 times.
11744746 if(family !=eeGANON && hclk>0 && get_bit(quest_rules,qr_ENEMIESFLICKER))
6430 {
6431
2/2
✓ Branch 0 taken 11067 times.
✓ Branch 1 taken 110796 times.
121863 if((frame&1)==1)
6432 110796 sprite::drawzcboss(dest);
6433 121863 }
6434 else
6435 11622883 sprite::drawzcboss(dest);
6436 }
6437
6438 11744746 cs=cshold;
6439 11747266 }
6440
6441
6442 // similar to the overblock function--can do up to a 32x32 sprite
6443 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
6444 57923 void enemy::drawblock(BITMAP *dest,int32_t mask)
6445 {
6446 57923 int32_t thold=tile;
6447 57923 int32_t t1=tile;
6448 57923 int32_t t2=tile+20;
6449 57923 int32_t t3=tile+1;
6450 57923 int32_t t4=tile+21;
6451
6452
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 57923 times.
57923 switch(mask)
6453 {
6454 case 1:
6455 enemy::drawzcboss(dest);
6456 break;
6457
6458 case 3:
6459 if(flip&2)
6460 zc_swap(t1,t2);
6461
6462 tile=t1;
6463 enemy::drawzcboss(dest);
6464 tile=t2;
6465 yofs+=16;
6466 enemy::drawzcboss(dest);
6467 yofs-=16;
6468 break;
6469
6470 case 5:
6471 t2=tile+1;
6472
6473 if(flip&1)
6474 zc_swap(t1,t2);
6475
6476 tile=t1;
6477 enemy::drawzcboss(dest);
6478 tile=t2;
6479 xofs+=16;
6480 enemy::drawzcboss(dest);
6481 xofs-=16;
6482 break;
6483
6484 case 15:
6485
2/2
✓ Branch 0 taken 55575 times.
✓ Branch 1 taken 2348 times.
57923 if(flip&1)
6486 {
6487 2348 zc_swap(t1,t3);
6488 2348 zc_swap(t2,t4);
6489 2348 }
6490
6491
1/2
✓ Branch 0 taken 57923 times.
✗ Branch 1 not taken.
57923 if(flip&2)
6492 {
6493 zc_swap(t1,t2);
6494 zc_swap(t3,t4);
6495 }
6496
6497 57923 tile=t1;
6498 57923 enemy::drawzcboss(dest);
6499 57923 tile=t2;
6500 57923 yofs+=16;
6501 57923 enemy::drawzcboss(dest);
6502 57923 yofs-=16;
6503 57923 tile=t3;
6504 57923 xofs+=16;
6505 57923 enemy::drawzcboss(dest);
6506 57923 tile=t4;
6507 57923 yofs+=16;
6508 57923 enemy::drawzcboss(dest);
6509 57923 xofs-=16;
6510 57923 yofs-=16;
6511 57923 break;
6512 }
6513
6514 57923 tile=thold;
6515 57923 }
6516
6517 1866066 void enemy::drawshadow(BITMAP *dest, bool translucent)
6518 {
6519
4/4
✓ Branch 0 taken 1699042 times.
✓ Branch 1 taken 167024 times.
✓ Branch 2 taken 24300 times.
✓ Branch 3 taken 1674742 times.
1866066 if(dont_draw() || isSideViewGravity())
6520 {
6521 191324 return;
6522 }
6523
6524
2/2
✓ Branch 0 taken 34870 times.
✓ Branch 1 taken 1639872 times.
1674742 if(dying)
6525 {
6526 34870 return;
6527 }
6528
6529
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1639872 times.
✓ Branch 2 taken 95543 times.
✓ Branch 3 taken 1544329 times.
1639872 if(((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
6530 1639872 (darkroom))
6531 {
6532 95543 return;
6533 }
6534 else
6535 {
6536
4/4
✓ Branch 0 taken 1525373 times.
✓ Branch 1 taken 18956 times.
✓ Branch 2 taken 1520693 times.
✓ Branch 3 taken 4680 times.
1544329 if(enemycanfall(id, false) && shadowtile == 0)
6537 4680 shadowtile = wpnsbuf[spr_shadow].tile;
6538
6539
5/6
✓ Branch 0 taken 1212250 times.
✓ Branch 1 taken 332079 times.
✓ Branch 2 taken 1212250 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1193294 times.
✓ Branch 5 taken 18956 times.
1544329 if(z>0 || fakez>0 || !enemycanfall(id, false))
6540 {
6541
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 350919 times.
351035 if(!shadow_overpit(this))
6542 350919 sprite::drawshadow(dest,translucent);
6543 351035 }
6544 }
6545 1866066 }
6546
6547 60821 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
6548 {
6549 60821 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
6550
6551
1/2
✓ Branch 0 taken 60821 times.
✗ Branch 1 not taken.
60821 if(sub!=NULL)
6552 {
6553 60821 xofs-=mx;
6554 60821 yofs-=my;
6555 60821 enemy::draw(sub);
6556 60821 xofs+=mx;
6557 60821 yofs+=my;
6558 60821 destroy_bitmap(sub);
6559 60821 }
6560 else
6561 enemy::draw(dest);
6562 60821 }
6563
6564 // override hit detection to check for invicibility, stunned, etc
6565 52704 bool enemy::hit(sprite *s)
6566 {
6567
3/6
✓ Branch 0 taken 52704 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52704 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 52704 times.
52704 if(!(s->scriptcoldet&1) || s->fallclk || s->drownclk) return false;
6568
6569
2/4
✓ Branch 0 taken 52704 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52704 times.
✗ Branch 3 not taken.
52704 return (dying || hclk>0) ? false : sprite::hit(s);
6570 52704 }
6571
6572 14929380 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
6573 {
6574
4/4
✓ Branch 0 taken 14680273 times.
✓ Branch 1 taken 249107 times.
✓ Branch 2 taken 14223828 times.
✓ Branch 3 taken 456445 times.
14929380 return (dying || hclk>0) ? false : sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
6575 }
6576 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
6577 {
6578 return (dying || hclk>0) ? false : sprite::hit(tx,ty,txsz2,tysz2);
6579 }
6580
6581 4507139 bool enemy::hit(weapon *w)
6582 {
6583
4/6
✓ Branch 0 taken 4415731 times.
✓ Branch 1 taken 91408 times.
✓ Branch 2 taken 4415731 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4415731 times.
4507139 if(!(w->scriptcoldet&1) || w->fallclk || w->drownclk) return false;
6584
6585
4/4
✓ Branch 0 taken 4309563 times.
✓ Branch 1 taken 106168 times.
✓ Branch 2 taken 4099176 times.
✓ Branch 3 taken 210387 times.
4415731 return (dying || hclk>0) ? false : sprite::hit(w);
6586 4507139 }
6587
6588 4646262 bool enemy::can_pitfall(bool checkspawning)
6589 {
6590
4/4
✓ Branch 0 taken 4642712 times.
✓ Branch 1 taken 3550 times.
✓ Branch 2 taken 4640193 times.
✓ Branch 3 taken 6069 times.
4646262 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
6591
2/2
✓ Branch 0 taken 4636450 times.
✓ Branch 1 taken 3743 times.
4640193 switch(guysbuf[id&0xFFF].family)
6592 {
6593 case eeAQUA:
6594 case eeDIG:
6595 case eeDONGO:
6596 case eeFAIRY:
6597 case eeGANON:
6598 case eeGHOMA:
6599 case eeGLEEOK:
6600 case eeGUY:
6601 case eeLANM:
6602 case eeMANHAN:
6603 case eeMOLD:
6604 case eeNONE:
6605 case eePATRA:
6606 case eeZORA:
6607 3743 return false; //Disallowed types
6608 default:
6609 4636450 return true;
6610 }
6611 4646262 }
6612 //Handle death
6613 10715186 void enemy::try_death(bool force_kill)
6614 {
6615
7/8
✓ Branch 0 taken 10712674 times.
✓ Branch 1 taken 2512 times.
✓ Branch 2 taken 10712674 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11593 times.
✓ Branch 5 taken 10701081 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 11592 times.
10715186 if(!dying && (force_kill || (hp<=0 && !immortal)))
6616 {
6617 11592 std::vector<int32_t> &ev = FFCore.eventData;
6618 11592 ev.clear();
6619 11592 ev.push_back(10000);
6620 11592 ev.push_back(getUID());
6621
6622 11592 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
6623 11592 bool isSaved = !ev[0];
6624 11592 ev.clear();
6625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11592 times.
11592 if(isSaved) return;
6626
6627
4/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 11578 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 12 times.
11592 if(itemguy && (hasitem&2)!=0)
6628 {
6629
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 12 times.
26 for(int32_t i=0; i<items.Count(); i++)
6630 {
6631
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12 times.
14 if(((item*)items.spr(i))->pickup&ipENEMY)
6632 {
6633
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if (!get_bit(quest_rules, qr_BROKEN_ITEM_CARRYING))
6634 {
6635 if (get_bit(quest_rules, qr_ENEMY_DROPS_USE_HITOFFSETS))
6636 {
6637 items.spr(i)->x = x+hxofs+(hxsz/2)-8;
6638 items.spr(i)->y = y+hyofs+(hysz/2)-10-fakez;
6639 }
6640 else
6641 {
6642 if(extend >= 3)
6643 {
6644 items.spr(i)->x = x+(txsz-1)*8;
6645 items.spr(i)->y = y-2+(tysz-1)*8;
6646 }
6647 else
6648 {
6649 items.spr(i)->x = x;
6650 items.spr(i)->y = y - 2;
6651 }
6652 }
6653 items.spr(i)->z = z;
6654 items.spr(i)->fakez = fakez;
6655 }
6656 else
6657 {
6658 12 items.spr(i)->x = x;
6659 12 items.spr(i)->y = y - 2;
6660 }
6661 12 }
6662 14 }
6663 12 }
6664
6665 11592 dying=true;
6666
6667
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 11571 times.
11592 if(fading==fade_flash_die)
6668 21 clk2=19+18*4;
6669 else
6670 {
6671 11571 clk2 = BSZ ? 15 : 19;
6672
6673
2/2
✓ Branch 0 taken 1113 times.
✓ Branch 1 taken 10458 times.
11571 if(fading!=fade_blue_poof)
6674 10458 fading=0;
6675 }
6676
6677
2/2
✓ Branch 0 taken 11578 times.
✓ Branch 1 taken 14 times.
11592 if(itemguy)
6678 {
6679 14 hasitem&=~2;
6680 14 item_set=0;
6681 14 }
6682
6683
6/6
✓ Branch 0 taken 11071 times.
✓ Branch 1 taken 521 times.
✓ Branch 2 taken 8156 times.
✓ Branch 3 taken 2915 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 8132 times.
11592 if(currscr<128 && count_enemy && !script_spawned)
6684 8132 game->guys[(currmap<<7)+currscr]-=1;
6685 11592 }
6686 10715186 }
6687
6688 // --==**==--
6689
6690 // Movement routines that can be used by derived classes as needed
6691
6692 // --==**==--
6693
6694 166744 void enemy::fix_coords(bool bound)
6695 {
6696
1/2
✓ Branch 0 taken 166744 times.
✗ Branch 1 not taken.
166744 if ((get_bit(quest_rules,qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
6697
1/2
✓ Branch 0 taken 166744 times.
✗ Branch 1 not taken.
166744 if(moveflags & FLAG_IGNORE_SCREENEDGE) bound = false;
6698
6699
6700
2/2
✓ Branch 0 taken 23283 times.
✓ Branch 1 taken 143461 times.
166744 if(bound)
6701 {
6702
1/2
✓ Branch 0 taken 143461 times.
✗ Branch 1 not taken.
143461 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
6703 {
6704
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 143461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
143461 x=vbound(x, 0, (( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_WIDTH && !isflier(id) ) ? (256-((txsz-1)*16)) : 240));
6705
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 143461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
143461 y=vbound(y, 0,(( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (176-((txsz-1)*16)) : 160));
6706 143461 }
6707 else
6708 {
6709 x=vbound(x, 0,240);
6710 y=vbound(y, 0,160);
6711 }
6712 143461 }
6713
6714
6/10
✓ Branch 0 taken 165800 times.
✓ Branch 1 taken 944 times.
✓ Branch 2 taken 166744 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 166744 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 166744 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 166744 times.
166744 if(!OUTOFBOUNDS)
6715 {
6716 /*x=((int32_t(x)&0xF0)+((int32_t(x)&8)?16:0));
6717
6718 if(isSideViewGravity())
6719 y=((int32_t(y)&0xF8)+((int32_t(y)&4)?8:0));
6720 else
6721 y=((int32_t(y)&0xF0)+((int32_t(y)&8)?16:0));
6722 */
6723 166744 do_fix(x, 16, true);
6724
2/2
✓ Branch 0 taken 944 times.
✓ Branch 1 taken 165800 times.
166744 if(isSideViewGravity())
6725 944 do_fix(y,8,true);
6726 165800 else do_fix(y,16,true);
6727 166744 }
6728 166744 }
6729 3530 bool enemy::cannotpenetrate()
6730 {
6731
4/4
✓ Branch 0 taken 3457 times.
✓ Branch 1 taken 73 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 3453 times.
3530 return (family == eeAQUA || family == eeMANHAN || family == eeGHOMA);
6732 }
6733
6734 167 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6735 {
6736 bool ok;
6737 167 int32_t dx = 0, dy = 0;
6738 167 int32_t sv = 8;
6739
6740 //Why is this here??? Why is it needed???
6741 167 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
6742
6743
8/9
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 20 times.
✓ Branch 4 taken 25 times.
✓ Branch 5 taken 20 times.
✓ Branch 6 taken 20 times.
✓ Branch 7 taken 27 times.
✗ Branch 8 not taken.
167 switch(ndir)
6744 {
6745 case 8:
6746 case up:
6747
3/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
24 if(canfall(id) && isSideViewGravity())
6748 return false;
6749
6750 24 dy = dy1-s;
6751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 special = (special==spw_clipbottomright)?spw_none:special;
6752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
6753 24 break;
6754
6755 case 12:
6756 case down:
6757
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
18 if(canfall(id) && isSideViewGravity())
6758 return false;
6759
6760 18 dy = dy2+s;
6761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
6762 18 break;
6763
6764 case 14:
6765 case left:
6766 13 dx = dx1-s;
6767 13 sv = ((isSideViewGravity())?7:8);
6768
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
6769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
6770 13 break;
6771
6772 case 10:
6773 case right:
6774 20 dx = dx2+s;
6775 20 sv = ((isSideViewGravity())?7:8);
6776
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 16 times.
20 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
6777 20 break;
6778
6779 case 9:
6780 case r_up:
6781 25 dx = dx2+s;
6782 25 dy = dy1-s;
6783
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
50 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
6784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
6785 25 break;
6786
6787 case 11:
6788 case r_down:
6789 20 dx = dx2+s;
6790 20 dx = dy2+s;
6791
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
40 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
6792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
6793 20 break;
6794
6795 case 13:
6796 case l_down:
6797 20 dx = dx1-s;
6798 20 dy = dy2+s;
6799
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
38 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
6800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
6801 20 break;
6802
6803 case 15:
6804 case l_up:
6805 27 dx = dx1-s;
6806 27 dy = dy1-s;
6807
2/4
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
54 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
6808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
6809 27 break;
6810
6811 default:
6812 db=99;
6813 return true;
6814 }
6815
6816 167 return ok;
6817 167 }
6818
6819
6820
6821
6822 // returns true if next step is ok, false if there is something there
6823 1989268 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
6824 {
6825 1989268 bool ok = false; //initialise the var, son't just declare it
6826 1989268 int32_t dx = 0, dy = 0;
6827 1989268 int32_t sv = 8;
6828 1989268 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
6829 //Why is this here??? Why is it needed???
6830 1989268 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
6831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1989268 times.
1989268 int32_t usexoffs = (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
6832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1989268 times.
1989268 int32_t useyoffs = (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
6833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1989268 times.
1989268 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hxsz : 16;
6834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1989268 times.
1989268 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hysz : 16;
6835 1989268 bool offgrid = OFFGRID_ENEMY;
6836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1989268 times.
1989268 if(!offgrid)
6837 {
6838 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
6839
1/2
✓ Branch 0 taken 1989268 times.
✗ Branch 1 not taken.
1989268 if(usehei<16)usehei=16;
6840
1/2
✓ Branch 0 taken 1989268 times.
✗ Branch 1 not taken.
1989268 if(usewid<16)usewid=16;
6841 1989268 }
6842
9/9
✓ Branch 0 taken 336981 times.
✓ Branch 1 taken 279230 times.
✓ Branch 2 taken 324308 times.
✓ Branch 3 taken 332100 times.
✓ Branch 4 taken 165633 times.
✓ Branch 5 taken 196206 times.
✓ Branch 6 taken 180803 times.
✓ Branch 7 taken 173948 times.
✓ Branch 8 taken 59 times.
1989268 switch(ndir) //need to check every 8 pixels between two points
6843 {
6844 case 8:
6845 case up:
6846 {
6847
4/4
✓ Branch 0 taken 75433 times.
✓ Branch 1 taken 261548 times.
✓ Branch 2 taken 75242 times.
✓ Branch 3 taken 191 times.
336981 if(enemycanfall(id) && isSideViewGravity())
6848 191 return false;
6849
6850 336790 dy = dy1-s;
6851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 336790 times.
336790 special = (special==spw_clipbottomright)?spw_none:special;
6852 336790 tries = usewid/(offgrid ? 8 : 16);
6853 //Z_eventlog("Trying move UP, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
6854
2/2
✓ Branch 0 taken 291917 times.
✓ Branch 1 taken 336790 times.
628707 for ( ; tries > 0; --tries )
6855 {
6856
2/2
✓ Branch 0 taken 43742 times.
✓ Branch 1 taken 293048 times.
336790 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
6857 336790 try_x += (offgrid ? 8 : 16);
6858
2/2
✓ Branch 0 taken 291917 times.
✓ Branch 1 taken 44873 times.
336790 if (!ok) break;
6859 291917 }
6860
2/2
✓ Branch 0 taken 291917 times.
✓ Branch 1 taken 44873 times.
336790 if(!ok) break;
6861
1/2
✓ Branch 0 taken 291917 times.
✗ Branch 1 not taken.
291917 if((usewid%16)>0) //Uneven width
6862 {
6863 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
6864 }
6865 291917 break;
6866 }
6867 case 12:
6868 case down:
6869 {
6870
4/4
✓ Branch 0 taken 80973 times.
✓ Branch 1 taken 198257 times.
✓ Branch 2 taken 80755 times.
✓ Branch 3 taken 218 times.
279230 if(enemycanfall(id) && isSideViewGravity())
6871 218 return false;
6872
6873 279012 dy = dy2+s;
6874 279012 tries = usewid/(offgrid ? 8 : 16);
6875 //Z_eventlog("Trying move DOWN, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
6876
2/2
✓ Branch 0 taken 231470 times.
✓ Branch 1 taken 279012 times.
510482 for ( ; tries > 0; --tries )
6877 {
6878
3/4
✓ Branch 0 taken 47532 times.
✓ Branch 1 taken 231480 times.
✓ Branch 2 taken 231480 times.
✗ Branch 3 not taken.
279012 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
6879 279012 try_x += (offgrid ? 8 : 16);
6880
2/2
✓ Branch 0 taken 231470 times.
✓ Branch 1 taken 47542 times.
279012 if (!ok) break;
6881 231470 }
6882
2/2
✓ Branch 0 taken 231470 times.
✓ Branch 1 taken 47542 times.
279012 if(!ok) break;
6883
1/2
✓ Branch 0 taken 231470 times.
✗ Branch 1 not taken.
231470 if((usewid%16)>0) //Uneven width
6884 {
6885 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
6886 }
6887 231470 break;
6888 }
6889 case 14:
6890 case left:
6891 {
6892 324308 dx = dx1-s;
6893 324308 sv = ((isSideViewGravity())?7:0);
6894
3/4
✓ Branch 0 taken 324308 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 857 times.
✓ Branch 3 taken 323451 times.
324308 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
6895 324308 tries = usehei/(offgrid ? 8 : 16);
6896 //Z_eventlog("Trying move LEFT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
6897
2/2
✓ Branch 0 taken 284029 times.
✓ Branch 1 taken 324308 times.
608337 for ( ; tries > 0; --tries )
6898 {
6899
2/2
✓ Branch 0 taken 39973 times.
✓ Branch 1 taken 284335 times.
324308 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
6900 324308 try_y += (offgrid ? 8 : 16);
6901
2/2
✓ Branch 0 taken 284029 times.
✓ Branch 1 taken 40279 times.
324308 if (!ok) break;
6902 284029 }
6903
2/2
✓ Branch 0 taken 284029 times.
✓ Branch 1 taken 40279 times.
324308 if(!ok) break;
6904
1/2
✓ Branch 0 taken 284029 times.
✗ Branch 1 not taken.
284029 if((usehei%16)>0) //Uneven height
6905 {
6906 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
6907 }
6908 284029 break;
6909 }
6910 case 10:
6911 case right:
6912 {
6913 332100 dx = dx2+s;
6914 332100 sv = ((isSideViewGravity())?7:0);
6915 332100 tries = usehei/(offgrid ? 8 : 16);
6916 //Z_eventlog("Trying move RIGHT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
6917
2/2
✓ Branch 0 taken 292344 times.
✓ Branch 1 taken 332100 times.
624444 for ( ; tries > 0; --tries )
6918 {
6919
3/4
✓ Branch 0 taken 39457 times.
✓ Branch 1 taken 292643 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 292643 times.
332100 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
6920 332100 try_y += (offgrid ? 8 : 16);
6921
2/2
✓ Branch 0 taken 292344 times.
✓ Branch 1 taken 39756 times.
332100 if (!ok) break;
6922 292344 }
6923
2/2
✓ Branch 0 taken 292344 times.
✓ Branch 1 taken 39756 times.
332100 if(!ok) break;
6924
1/2
✓ Branch 0 taken 292344 times.
✗ Branch 1 not taken.
292344 if((usehei%16)>0) //Uneven height
6925 {
6926 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
6927 }
6928 292344 break;
6929 }
6930 case 9:
6931 case r_up:
6932 {
6933 165633 dx = dx2+s;
6934 165633 dy = dy1-s;
6935 165633 int32_t tries_x = usewid/(offgrid ? 8 : 16);
6936 165633 sv = ((isSideViewGravity())?7:0);
6937
2/2
✓ Branch 0 taken 160031 times.
✓ Branch 1 taken 165633 times.
325664 for ( ; tries_x > 0; --tries_x )
6938 {
6939 165633 int32_t tries_y = usehei/(offgrid ? 8 : 16);
6940 165633 try_y = 0;
6941
2/2
✓ Branch 0 taken 160031 times.
✓ Branch 1 taken 165633 times.
325664 for ( ; tries_y > 0; --tries_y )
6942 {
6943
4/4
✓ Branch 0 taken 163421 times.
✓ Branch 1 taken 2212 times.
✓ Branch 2 taken 161512 times.
✓ Branch 3 taken 1909 times.
327145 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
6944
2/2
✓ Branch 0 taken 1140 times.
✓ Branch 1 taken 160372 times.
161512 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
6945 165633 try_y += (offgrid ? 8 : 16);
6946
2/2
✓ Branch 0 taken 160031 times.
✓ Branch 1 taken 5602 times.
165633 if (!ok) break;
6947 160031 }
6948
2/2
✓ Branch 0 taken 160031 times.
✓ Branch 1 taken 5602 times.
165633 if (!ok) break;
6949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160031 times.
160031 if((usehei%16)>0) //Uneven height
6950 {
6951 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
6952 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
6953 }
6954 160031 try_x += (offgrid ? 8 : 16);
6955 160031 }
6956
2/2
✓ Branch 0 taken 160031 times.
✓ Branch 1 taken 5602 times.
165633 if(!ok) break;
6957
1/2
✓ Branch 0 taken 160031 times.
✗ Branch 1 not taken.
160031 if((usewid%16)>0) //Uneven width
6958 {
6959 int32_t tries_y = usehei/(offgrid ? 8 : 16);
6960 try_y = 0;
6961 for ( ; tries_y > 0; --tries_y )
6962 {
6963 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
6964 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
6965 try_y += (offgrid ? 8 : 16);
6966 if (!ok) break;
6967 }
6968 if (!ok) break;
6969 if((usehei%16)>0) //Uneven height
6970 {
6971 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
6972 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
6973 }
6974 }
6975 160031 break;
6976 }
6977 case 11:
6978 case r_down:
6979 {
6980 196206 dx = dx2+s;
6981 196206 dx = dy2+s;
6982 196206 int32_t tries_x = usewid/(offgrid ? 8 : 16);
6983 //sv = ((isSideViewGravity())?7:0);
6984
2/2
✓ Branch 0 taken 191601 times.
✓ Branch 1 taken 196206 times.
387807 for ( ; tries_x > 0; --tries_x )
6985 {
6986 196206 int32_t tries_y = usehei/(offgrid ? 8 : 16);
6987 196206 try_y = 0;
6988
2/2
✓ Branch 0 taken 191601 times.
✓ Branch 1 taken 196206 times.
387807 for ( ; tries_y > 0; --tries_y )
6989 {
6990
4/4
✓ Branch 0 taken 196134 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 191606 times.
✓ Branch 3 taken 4528 times.
387812 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
6991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 191606 times.
191606 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
6992 196206 try_y += (offgrid ? 8 : 16);
6993
2/2
✓ Branch 0 taken 191601 times.
✓ Branch 1 taken 4605 times.
196206 if (!ok) break;
6994 191601 }
6995
2/2
✓ Branch 0 taken 191601 times.
✓ Branch 1 taken 4605 times.
196206 if (!ok) break;
6996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 191601 times.
191601 if((usehei%16)>0) //Uneven height
6997 {
6998 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
6999 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
7000 }
7001 191601 try_x += (offgrid ? 8 : 16);
7002 191601 }
7003
2/2
✓ Branch 0 taken 191601 times.
✓ Branch 1 taken 4605 times.
196206 if(!ok) break;
7004
1/2
✓ Branch 0 taken 191601 times.
✗ Branch 1 not taken.
191601 if((usewid%16)>0) //Uneven width
7005 {
7006 int32_t tries_y = usehei/(offgrid ? 8 : 16);
7007 try_y = 0;
7008 for ( ; tries_y > 0; --tries_y )
7009 {
7010 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
7011 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
7012 try_y += (offgrid ? 8 : 16);
7013 if (!ok) break;
7014 }
7015 if (!ok) break;
7016 if((usehei%16)>0) //Uneven height
7017 {
7018 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
7019 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
7020 }
7021 }
7022 191601 break;
7023 }
7024 case 13:
7025 case l_down:
7026 {
7027 180803 dx = dx1-s;
7028 180803 dy = dy2+s;
7029 180803 int32_t tries_x = usewid/(offgrid ? 8 : 16);
7030 //sv = ((isSideViewGravity())?7:0);
7031
2/2
✓ Branch 0 taken 175995 times.
✓ Branch 1 taken 180803 times.
356798 for ( ; tries_x > 0; --tries_x )
7032 {
7033 180803 int32_t tries_y = usehei/(offgrid ? 8 : 16);
7034 180803 try_y = 0;
7035
2/2
✓ Branch 0 taken 175995 times.
✓ Branch 1 taken 180803 times.
356798 for ( ; tries_y > 0; --tries_y )
7036 {
7037
4/4
✓ Branch 0 taken 177529 times.
✓ Branch 1 taken 3274 times.
✓ Branch 2 taken 175998 times.
✓ Branch 3 taken 1531 times.
356801 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
7038
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 175995 times.
175998 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
7039 180803 try_y += (offgrid ? 8 : 16);
7040
2/2
✓ Branch 0 taken 175995 times.
✓ Branch 1 taken 4808 times.
180803 if (!ok) break;
7041 175995 }
7042
2/2
✓ Branch 0 taken 175995 times.
✓ Branch 1 taken 4808 times.
180803 if (!ok) break;
7043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 175995 times.
175995 if((usehei%16)>0) //Uneven height
7044 {
7045 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
7046 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
7047 }
7048 175995 try_x += (offgrid ? 8 : 16);
7049 175995 }
7050
2/2
✓ Branch 0 taken 175995 times.
✓ Branch 1 taken 4808 times.
180803 if(!ok) break;
7051
1/2
✓ Branch 0 taken 175995 times.
✗ Branch 1 not taken.
175995 if((usewid%16)>0) //Uneven width
7052 {
7053 int32_t tries_y = usehei/(offgrid ? 8 : 16);
7054 try_y = 0;
7055 for ( ; tries_y > 0; --tries_y )
7056 {
7057 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
7058 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
7059 try_y += (offgrid ? 8 : 16);
7060 if (!ok) break;
7061 }
7062 if (!ok) break;
7063 if((usehei%16)>0) //Uneven height
7064 {
7065 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
7066 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
7067 }
7068 }
7069 175995 break;
7070 }
7071 case 15:
7072 case l_up:
7073 {
7074 173948 dx = dx1-s;
7075 173948 dy = dy1-s;
7076 173948 int32_t tries_x = usewid/(offgrid ? 8 : 16);
7077 173948 sv = ((isSideViewGravity())?7:0);
7078
2/2
✓ Branch 0 taken 168737 times.
✓ Branch 1 taken 173948 times.
342685 for ( ; tries_x > 0; --tries_x )
7079 {
7080 173948 int32_t tries_y = usehei/(offgrid ? 8 : 16);
7081 173948 try_y = 0;
7082
2/2
✓ Branch 0 taken 168737 times.
✓ Branch 1 taken 173948 times.
342685 for ( ; tries_y > 0; --tries_y )
7083 {
7084
4/4
✓ Branch 0 taken 171593 times.
✓ Branch 1 taken 2355 times.
✓ Branch 2 taken 170166 times.
✓ Branch 3 taken 1427 times.
344114 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
7085
2/2
✓ Branch 0 taken 1080 times.
✓ Branch 1 taken 169086 times.
170166 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
7086 173948 try_y += (offgrid ? 8 : 16);
7087
2/2
✓ Branch 0 taken 168737 times.
✓ Branch 1 taken 5211 times.
173948 if (!ok) break;
7088 168737 }
7089
2/2
✓ Branch 0 taken 168737 times.
✓ Branch 1 taken 5211 times.
173948 if (!ok) break;
7090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 168737 times.
168737 if((usehei%16)>0) //Uneven height
7091 {
7092 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
7093 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
7094 }
7095 168737 try_x += (offgrid ? 8 : 16);
7096 168737 }
7097
2/2
✓ Branch 0 taken 168737 times.
✓ Branch 1 taken 5211 times.
173948 if(!ok) break;
7098
1/2
✓ Branch 0 taken 168737 times.
✗ Branch 1 not taken.
168737 if((usewid%16)>0) //Uneven width
7099 {
7100 int32_t tries_y = usehei/(offgrid ? 8 : 16);
7101 try_y = 0;
7102 for ( ; tries_y > 0; --tries_y )
7103 {
7104 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
7105 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
7106 try_y += (offgrid ? 8 : 16);
7107 if (!ok) break;
7108 }
7109 if (!ok) break;
7110 if((usehei%16)>0) //Uneven height
7111 {
7112 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
7113 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
7114 }
7115 }
7116 168737 break;
7117 }
7118 default:
7119 59 db=99;
7120 59 return true;
7121 }
7122 //Z_eventlog("\n");
7123 1988800 return ok;
7124 1989268 }
7125
7126
7127 1359051 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
7128 {
7129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1359051 times.
1359051 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hxsz : 16;
7130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1359051 times.
1359051 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hysz : 16;
7131
1/2
✓ Branch 0 taken 1359051 times.
✗ Branch 1 not taken.
1359051 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
7132
1/2
✓ Branch 0 taken 1359051 times.
✗ Branch 1 not taken.
1359051 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
7133 1359051 --usewid;
7134 1359051 --usehei;
7135 1359051 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
7136 }
7137
7138 309299 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
7139 {
7140 309299 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
7141
7142
4/4
✓ Branch 0 taken 3239 times.
✓ Branch 1 taken 306060 times.
✓ Branch 2 taken 2485 times.
✓ Branch 3 taken 754 times.
309299 if(special==spw_clipright&&ndir==right)
7143 {
7144 754 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
7145 754 }
7146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 309299 times.
309299 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hxsz : 16;
7147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 309299 times.
309299 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hysz : 16;
7148
1/2
✓ Branch 0 taken 309299 times.
✗ Branch 1 not taken.
309299 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
7149
1/2
✓ Branch 0 taken 309299 times.
✗ Branch 1 not taken.
309299 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
7150 309299 --usewid;
7151 309299 --usehei;
7152
2/2
✓ Branch 0 taken 153002 times.
✓ Branch 1 taken 156297 times.
309299 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
7153 }
7154
7155 28313 bool enemy::canmove(int32_t ndir, bool kb)
7156 {
7157 28313 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
7158 }
7159
7160 // 8-directional
7161 167 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
7162 {
7163 167 int32_t ndir=0;
7164
7165 // can move straight, check if it wants to turn
7166
2/2
✓ Branch 0 taken 161 times.
✓ Branch 1 taken 6 times.
167 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
7167 {
7168
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 161 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
161 if(grumble && (zc_oldrand()&4)<grumble) //Homing
7169 {
7170 int32_t w = Lwpns.idFirst(wBait);
7171
7172 if(w>=0)
7173 {
7174 int32_t bx = Lwpns.spr(w)->x;
7175 int32_t by = Lwpns.spr(w)->y;
7176
7177 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
7178
7179 if(abs(int32_t(y)-by)>14)
7180 {
7181 if(ndir>0) // Already left or right
7182 {
7183 // Making the diagonal directions
7184 ndir += (by<y) ? 2 : 4;
7185 }
7186 else
7187 {
7188 ndir = (by<y) ? up : down;
7189 }
7190 }
7191
7192 if(canmove(ndir,special,false))
7193 {
7194 dir=ndir;
7195 return;
7196 }
7197 }
7198 }
7199
7200 // Homing added.
7201
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 161 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
161 if(newhoming && (zc_oldrand()&255)<newhoming)
7202 {
7203 ndir = lined_up(8,true);
7204
7205 if(ndir>=0 && canmove(ndir,special,false))
7206 {
7207 dir=ndir;
7208 }
7209
7210 return;
7211 }
7212
7213 161 int32_t r=zc_oldrand();
7214
7215
2/4
✓ Branch 0 taken 161 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 161 times.
161 if(newrate>0 && !(r%newrate))
7216 {
7217 161 ndir = ((dir+((r&64)?-1:1))&7)+8;
7218 161 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
7219
7220
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 5 times.
161 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7221 156 dir=ndir;
7222
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
5 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
7223 4 dir=ndir2;
7224
7225
3/4
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 156 times.
✗ Branch 3 not taken.
161 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
7226 // due to numerous lost fractional components. -L
7227 {
7228 x.doFloor();
7229 y.doFloor();
7230 }
7231 161 }
7232
7233 161 return;
7234 }
7235
7236 // can't move straight, must turn
7237 6 int32_t i=0;
7238
7239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 for(; i<32; i++) // Try random dir
7240 {
7241 10 ndir=(zc_oldrand()&7)+8;
7242
7243
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 6 times.
10 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7244 6 break;
7245 4 }
7246
7247
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(i==32)
7248 {
7249 for(ndir=8; ndir<16; ndir++)
7250 {
7251 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7252 goto ok;
7253 }
7254
7255 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
7256 }
7257
7258 ok:
7259 6 dir=ndir;
7260 6 x.doFloor();
7261 6 y.doFloor();
7262 167 }
7263
7264 170248 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
7265 {
7266 170248 int32_t ndir=0;
7267
7268 // can move straight, check if it wants to turn
7269
2/2
✓ Branch 0 taken 159697 times.
✓ Branch 1 taken 10551 times.
170248 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
7270 {
7271
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 159697 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
159697 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
7272 {
7273 int32_t i = Lwpns.idFirst(wBait);
7274 if(i >= 0) //idfirst returns -1 if it can't find any
7275 {
7276 weapon *w = (weapon*)Lwpns.spr(i);
7277 if (get_bit(quest_rules, qr_FIND_CLOSEST_BAIT))
7278 {
7279 int32_t currentrange;
7280 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
7281 else currentrange = -1;
7282 int curid = i;
7283 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
7284 for(; i<Lwpns.Count(); ++i)
7285 {
7286 weapon *lw = (weapon*)Lwpns.spr(i);
7287 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
7288 {
7289 currentrange = distance(x, y, lw->x, lw->y);
7290 curid = i;
7291 }
7292 }
7293 i = curid;
7294 if (currentrange == -1) i = -1;
7295 }
7296 else
7297 {
7298 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
7299 }
7300 if(i>=0)
7301 {
7302 int32_t bx = Lwpns.spr(i)->x;
7303 int32_t by = Lwpns.spr(i)->y;
7304
7305 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
7306
7307 if(abs(int32_t(y)-by)>14)
7308 {
7309 if(ndir>0) // Already left or right
7310 {
7311 // Making the diagonal directions
7312 ndir += (by<y) ? 2 : 4;
7313 }
7314 else
7315 {
7316 ndir = (by<y) ? up : down;
7317 }
7318 }
7319 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
7320 if(canmove(ndir,special,false))
7321 {
7322 dir=ndir;
7323 return;
7324 }
7325 }
7326 }
7327 }
7328
7329 // Homing added.
7330
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 159697 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
159697 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
7331 {
7332 ndir = lined_up(8,true);
7333 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
7334 if(ndir>=0 && canmove(ndir,special,false))
7335 {
7336 dir=ndir;
7337 }
7338
7339 return;
7340 }
7341
7342 159697 int32_t r=zc_oldrand();
7343
7344
4/4
✓ Branch 0 taken 109885 times.
✓ Branch 1 taken 49812 times.
✓ Branch 2 taken 58598 times.
✓ Branch 3 taken 51287 times.
159697 if(newrate>0 && !(r%newrate))
7345 {
7346 51287 ndir = ((dir+((r&64)?-1:1))&7)+8;
7347 51287 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
7348
7349
2/2
✓ Branch 0 taken 49635 times.
✓ Branch 1 taken 1652 times.
51287 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7350 49635 dir=ndir;
7351
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1651 times.
1652 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
7352 1651 dir=ndir2;
7353
7354
4/4
✓ Branch 0 taken 49635 times.
✓ Branch 1 taken 1652 times.
✓ Branch 2 taken 48059 times.
✓ Branch 3 taken 1576 times.
51287 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
7355 // due to numerous lost fractional components. -L
7356 {
7357 1576 x.doFloor();
7358 1576 y.doFloor();
7359 1576 }
7360 51287 }
7361
7362 159697 return;
7363 }
7364
7365 // can't move straight, must turn
7366 10551 int32_t i=0;
7367
7368
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 19674 times.
19681 for(; i<32; i++) // Try random dir
7369 {
7370 19674 ndir=(zc_oldrand()&7)+8;
7371
7372
2/2
✓ Branch 0 taken 9130 times.
✓ Branch 1 taken 10544 times.
19674 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7373 10544 break;
7374 9130 }
7375
7376
2/2
✓ Branch 0 taken 10544 times.
✓ Branch 1 taken 7 times.
10551 if(i==32)
7377 {
7378
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 for(ndir=8; ndir<16; ndir++)
7379 {
7380
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7 times.
9 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7381 7 goto ok;
7382 2 }
7383
7384 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
7385 }
7386
7387 ok:
7388 10551 dir=ndir;
7389 10551 x.doFloor();
7390 10551 y.doFloor();
7391 170248 }
7392
7393 168020 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
7394 {
7395 168020 newdir_8(newrate,newhoming,special,0,-8,15,15);
7396 168020 }
7397
7398 167 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
7399 {
7400 167 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
7401 167 }
7402
7403 // makes the enemy slide backwards when hit
7404 // sclk: first byte is clk, second byte is dir
7405 // makes the enemy slide backwards when hit
7406 // sclk: first byte is clk, second byte is dir
7407 4660402 int32_t enemy::slide()
7408 {
7409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4660402 times.
4660402 if(script_knockback_clk!=0) //scripted knockback
7410 {
7411 sclk = 0;
7412 return 1; //scripted knockback ran
7413 }
7414
5/6
✓ Branch 0 taken 32786 times.
✓ Branch 1 taken 4627616 times.
✓ Branch 2 taken 3653 times.
✓ Branch 3 taken 29133 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3653 times.
4660402 if(sclk==0 || (hp<=0 && !immortal))
7415 4631269 return 0;
7416
7417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29133 times.
29133 if(knockbackflags & FLAG_NOSLIDE)
7418 {
7419 sclk = 0;
7420 if(!OFFGRID_ENEMY)
7421 {
7422 //Fix to grid
7423 //x = (int32_t(x)+8)-((int32_t(x)+8)%16);
7424 //y = (int32_t(y)+8)-((int32_t(y)+8)%16);
7425 do_fix(x, 16, true);
7426 do_fix(y, 16, true);
7427 }
7428 return 0;
7429 }
7430
8/10
✓ Branch 0 taken 2937 times.
✓ Branch 1 taken 26196 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 2912 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
✓ Branch 6 taken 2159 times.
✓ Branch 7 taken 753 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 25 times.
29133 if((sclk&255)==16 && (get_bit(quest_rules,qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
7431 {
7432 753 sclk=0;
7433 753 return 0;
7434 }
7435
7436 28380 --sclk;
7437
7438
5/5
✓ Branch 0 taken 273 times.
✓ Branch 1 taken 2770 times.
✓ Branch 2 taken 3299 times.
✓ Branch 3 taken 10233 times.
✓ Branch 4 taken 11805 times.
28380 switch(sclk>>8)
7439 {
7440 case up:
7441 {
7442
4/4
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 2486 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 2764 times.
2770 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_bit(quest_rules,qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
7443 {
7444 6 sclk=0;
7445 6 return 0;
7446 }
7447
4/4
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 2480 times.
✓ Branch 2 taken 237 times.
✓ Branch 3 taken 47 times.
2764 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
7448
7449 2717 break;
7450 }
7451 case down:
7452 {
7453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3299 times.
3299 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
7454 {
7455 sclk=0;
7456 return 0;
7457 }
7458
4/4
✓ Branch 0 taken 460 times.
✓ Branch 1 taken 2839 times.
✓ Branch 2 taken 390 times.
✓ Branch 3 taken 70 times.
3299 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
7459
7460 3229 break;
7461 }
7462 case left:
7463 {
7464
4/4
✓ Branch 0 taken 924 times.
✓ Branch 1 taken 9309 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 10220 times.
10233 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_bit(quest_rules,qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
7465 {
7466 13 sclk=0;
7467 13 return 0;
7468 }
7469
4/4
✓ Branch 0 taken 924 times.
✓ Branch 1 taken 9296 times.
✓ Branch 2 taken 846 times.
✓ Branch 3 taken 78 times.
10220 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
7470
7471 10142 break;
7472 }
7473 case right:
7474 {
7475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11805 times.
11805 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
7476 {
7477 sclk=0;
7478 return 0;
7479 }
7480
4/4
✓ Branch 0 taken 1751 times.
✓ Branch 1 taken 10054 times.
✓ Branch 2 taken 1640 times.
✓ Branch 3 taken 111 times.
11805 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
7481 11694 break;
7482 }
7483 }
7484
7485 28055 int32_t move = knockbackSpeed;
7486
2/2
✓ Branch 0 taken 26679 times.
✓ Branch 1 taken 28055 times.
54734 while(move>0)
7487 {
7488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28055 times.
28055 int32_t thismove = zc_min(8, move);
7489 28055 move -= thismove;
7490 28055 hitdir = (sclk>>8);
7491
5/5
✓ Branch 0 taken 273 times.
✓ Branch 1 taken 2717 times.
✓ Branch 2 taken 3229 times.
✓ Branch 3 taken 10142 times.
✓ Branch 4 taken 11694 times.
28055 switch(sclk>>8)
7492 {
7493 case up:
7494 2717 y-=thismove;
7495 2717 break;
7496
7497 case down:
7498 3229 y+=thismove;
7499 3229 break;
7500
7501 case left:
7502 10142 x-=thismove;
7503 10142 break;
7504
7505 case right:
7506 11694 x+=thismove;
7507 11694 break;
7508 }
7509
2/2
✓ Branch 0 taken 26679 times.
✓ Branch 1 taken 1376 times.
28055 if(!canmove(sclk>>8,(zfix)0,0,true))
7510 {
7511
3/3
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 863 times.
✓ Branch 2 taken 1 times.
1376 switch(sclk>>8)
7512 {
7513 case up:
7514 case down:
7515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 if(y < 0)
7516 y = 0;
7517
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 408 times.
512 else if((int32_t(y)&15) > 7)
7518 104 y=(int32_t(y)&0xF0)+16;
7519 else
7520 408 y=(int32_t(y)&0xF0);
7521
7522 512 break;
7523
7524 case left:
7525 case right:
7526
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 862 times.
863 if(x < 0)
7527 1 x = 0;
7528
2/2
✓ Branch 0 taken 250 times.
✓ Branch 1 taken 612 times.
862 else if((int32_t(x)&15) > 7)
7529 250 x=(int32_t(x)&0xF0)+16;
7530 else
7531 612 x=(int32_t(x)&0xF0);
7532
7533 863 break;
7534 }
7535
7536 1376 sclk=0;
7537 1376 clk3=0;
7538 1376 break;
7539 }
7540 }
7541
7542
2/2
✓ Branch 0 taken 25894 times.
✓ Branch 1 taken 2161 times.
28055 if((sclk&255)==0)
7543 {
7544 //hitdir = -1;
7545 2161 sclk=0;
7546 2161 }
7547 28055 return 2;
7548 4660402 }
7549
7550 bool enemy::can_slide()
7551 {
7552 if(sclk==0 || (hp<=0 && !immortal))
7553 return false;
7554
7555 if((sclk&255)==16 && (get_bit(quest_rules,qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
7556 {
7557 return false;
7558 }
7559
7560 return true;
7561 }
7562
7563 bool enemy::fslide()
7564 {
7565 if(sclk==0 || (hp<=0 && !immortal))
7566 return false;
7567
7568 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
7569 {
7570 sclk=0;
7571 return false;
7572 }
7573
7574 --sclk;
7575
7576 switch(sclk>>8)
7577 {
7578 case up:
7579 if(y<=16)
7580 {
7581 sclk=0;
7582 return false;
7583 }
7584
7585 break;
7586
7587 case down:
7588 if(y>=160)
7589 {
7590 sclk=0;
7591 return false;
7592 }
7593
7594 break;
7595
7596 case left:
7597 if(x<=16)
7598 {
7599 sclk=0;
7600 return false;
7601 }
7602
7603 break;
7604
7605 case right:
7606 if(x>=240)
7607 {
7608 sclk=0;
7609 return false;
7610 }
7611
7612 break;
7613 }
7614 hitdir = (sclk>>8);
7615 switch(sclk>>8)
7616 {
7617 case up:
7618 y-=4;
7619 break;
7620
7621 case down:
7622 y+=4;
7623 break;
7624
7625 case left:
7626 x-=4;
7627 break;
7628
7629 case right:
7630 x+=4;
7631 break;
7632 }
7633
7634 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
7635 {
7636 switch(sclk>>8)
7637 {
7638 case up:
7639 case down:
7640 if((int32_t(y)&15) > 7)
7641 y=(int32_t(y)&0xF0)+16;
7642 else
7643 y=(int32_t(y)&0xF0);
7644
7645 break;
7646
7647 case left:
7648 case right:
7649 if((int32_t(x)&15) > 7)
7650 x=(int32_t(x)&0xF0)+16;
7651 else
7652 x=(int32_t(x)&0xF0);
7653
7654 break;
7655 }
7656
7657 sclk=0;
7658 clk3=0;
7659 }
7660
7661 if((sclk&255)==0)
7662 sclk=0;
7663
7664 return true;
7665 }
7666
7667 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
7668 {
7669 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
7670 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
7671 bool ret = sprite::knockback(time, dir, speed);
7672 if(ret) sclk = 0; //kill engine knockback if interrupted
7673 //! Perhaps also set hitdir here, if needed for timing? -Z
7674 return ret;
7675 }
7676
7677 10715186 bool enemy::runKnockback()
7678 {
7679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10715186 times.
10715186 if((script_knockback_clk&0xFF)==0)
7680 {
7681 10715186 script_knockback_clk = 0;
7682 10715186 return false;
7683 }
7684 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
7685 {
7686 return false;
7687 }
7688 int32_t move = script_knockback_speed;
7689 int32_t kb_dir = script_knockback_clk>>8;
7690 --script_knockback_clk;
7691
7692 while(move>0)
7693 {
7694 int32_t thismove = zc_min(get_bit(quest_rules, qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
7695 move -= thismove;
7696 hitdir = kb_dir;
7697 switch(kb_dir)
7698 {
7699 case r_up:
7700 case l_up:
7701 case up:
7702 y-=thismove;
7703 break;
7704
7705 case r_down:
7706 case l_down:
7707 case down:
7708 y+=thismove;
7709 break;
7710 }
7711 switch(kb_dir)
7712 {
7713 case l_up:
7714 case l_down:
7715 case left:
7716 x-=thismove;
7717 break;
7718
7719 case r_up:
7720 case r_down:
7721 case right:
7722 x+=thismove;
7723 break;
7724 }
7725 if (get_bit(quest_rules, qr_OLD_SCRIPTED_KNOCKBACK))
7726 {
7727 if(!canmove(kb_dir,(zfix)0,0,true))
7728 {
7729 script_knockback_clk=0;
7730 clk3=0;
7731 //Fix to grid
7732 switch(kb_dir)
7733 {
7734 case up:
7735 case down:
7736 break;
7737 default:
7738 if(x < 0)
7739 x = 0;
7740 else if((int32_t(x)&15) > 7)
7741 x=(int32_t(x)&0xF0)+16;
7742 else
7743 x=(int32_t(x)&0xF0);
7744 break;
7745 }
7746 switch(kb_dir)
7747 {
7748 case left:
7749 case right:
7750 break;
7751 default:
7752 if(y < 0)
7753 y = 0;
7754 else if((int32_t(y)&15) > 7)
7755 y=(int32_t(y)&0xF0)+16;
7756 else
7757 y=(int32_t(y)&0xF0);
7758 break;
7759 }
7760 break;
7761 }
7762 }
7763 else
7764 {
7765 if(!scr_canplace(x,y,0,true))
7766 {
7767 script_knockback_clk=0;
7768 clk3=0;
7769 //Fix to grid
7770 if (OFFGRID_ENEMY)
7771 {
7772 switch(kb_dir)
7773 {
7774 case up:
7775 case down:
7776 break;
7777 default:
7778 if(x < 0)
7779 x = 0;
7780 else if((int32_t(x)&7) > 3)
7781 x=(int32_t(x)&0xF8)+8;
7782 else
7783 x=(int32_t(x)&0xF8);
7784 break;
7785 }
7786 switch(kb_dir)
7787 {
7788 case left:
7789 case right:
7790 break;
7791 default:
7792 if(y < 0)
7793 y = 0;
7794 else if((int32_t(y)&7) > 3)
7795 y=(int32_t(y)&0xF8)+8;
7796 else
7797 y=(int32_t(y)&0xF8);
7798 break;
7799 }
7800 }
7801 else
7802 {
7803 switch(kb_dir)
7804 {
7805 case up:
7806 case down:
7807 break;
7808 default:
7809 if(x < 0)
7810 x = 0;
7811 else if((int32_t(x)&15) > 7)
7812 x=(int32_t(x)&0xF0)+16;
7813 else
7814 x=(int32_t(x)&0xF0);
7815 break;
7816 }
7817 switch(kb_dir)
7818 {
7819 case left:
7820 case right:
7821 break;
7822 default:
7823 if(y < 0)
7824 y = 0;
7825 else if((int32_t(y)&15) > 7)
7826 y=(int32_t(y)&0xF0)+16;
7827 else
7828 y=(int32_t(y)&0xF0);
7829 break;
7830 }
7831 }
7832 break;
7833 }
7834
7835 }
7836 }
7837 return true;
7838 10715186 }
7839 // changes enemy's direction, checking restrictions
7840 // rate: 0 = no random changes, 16 = always random change
7841 // homing: 0 = none, 256 = always
7842 // grumble 0 = none, 4 = strongest appetite
7843 156039 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
7844 {
7845 156039 int32_t ndir=-1;
7846
7847
4/4
✓ Branch 0 taken 27106 times.
✓ Branch 1 taken 128933 times.
✓ Branch 2 taken 10109 times.
✓ Branch 3 taken 16997 times.
156039 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble)) //yes, I know checking if grumble is equal to if grumble == 0, but the latter makes the intention more clear to less experienced coders who might join.
7848 {
7849 16997 int32_t i = Lwpns.idFirst(wBait);
7850
1/2
✓ Branch 0 taken 16997 times.
✗ Branch 1 not taken.
16997 if(i >= 0) //idfirst returns -1 if it can't find any
7851 {
7852 weapon *w = (weapon*)Lwpns.spr(i);
7853 if (get_bit(quest_rules, qr_FIND_CLOSEST_BAIT))
7854 {
7855 int32_t currentrange;
7856 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
7857 else currentrange = -1;
7858 int curid = i;
7859 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
7860 for(; i<Lwpns.Count(); ++i)
7861 {
7862 weapon *lw = (weapon*)Lwpns.spr(i);
7863 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
7864 {
7865 currentrange = distance(x, y, lw->x, lw->y);
7866 curid = i;
7867 }
7868 }
7869 i = curid;
7870 if (currentrange == -1) i = -1;
7871 }
7872 else
7873 {
7874 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
7875 }
7876 if (i >= 0)
7877 {
7878 int32_t bx = Lwpns.spr(i)->x;
7879 int32_t by = Lwpns.spr(i)->y;
7880
7881 if(abs(int32_t(y)-by)>14)
7882 {
7883 ndir = (by<y) ? up : down;
7884 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
7885 if(canmove(ndir,special,false))
7886 {
7887 dir=ndir;
7888 return;
7889 }
7890 }
7891
7892 ndir = (bx<x) ? left : right;
7893 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
7894 if(canmove(ndir,special,false))
7895 {
7896 dir=ndir;
7897 return;
7898 }
7899 }
7900 }
7901 16997 }
7902
7903
2/2
✓ Branch 0 taken 107721 times.
✓ Branch 1 taken 48318 times.
156039 if((zc_oldrand()&255)<abs(newhoming))
7904 {
7905 48318 ndir = lined_up(8,false);
7906
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48318 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48318 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
7907
4/4
✓ Branch 0 taken 13196 times.
✓ Branch 1 taken 35122 times.
✓ Branch 2 taken 1565 times.
✓ Branch 3 taken 11631 times.
48318 if(ndir>=0 && canmove(ndir,special,false))
7908 {
7909 11631 dir=ndir;
7910 11631 return;
7911 }
7912 36687 }
7913
7914 144408 int32_t i=0;
7915
7916
2/2
✓ Branch 0 taken 319 times.
✓ Branch 1 taken 295419 times.
295738 for(; i<32; i++)
7917 {
7918 295419 int32_t r=zc_oldrand();
7919
7920
2/2
✓ Branch 0 taken 86268 times.
✓ Branch 1 taken 209151 times.
295419 if((r&15)<newrate)
7921 86268 ndir=(r>>4)&3;
7922 else
7923 209151 ndir=dir;
7924
7925
2/2
✓ Branch 0 taken 151330 times.
✓ Branch 1 taken 144089 times.
295419 if(canmove(ndir,special,false))
7926 144089 break;
7927 151330 }
7928
7929
2/2
✓ Branch 0 taken 144089 times.
✓ Branch 1 taken 319 times.
144431 if(i==32)
7930 {
7931
2/2
✓ Branch 0 taken 684 times.
✓ Branch 1 taken 23 times.
707 for(ndir=0; ndir<4; ndir++)
7932 {
7933
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 296 times.
684 if(canmove(ndir,special,false))
7934 296 goto ok;
7935 388 }
7936
7937
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 18 times.
23 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
7938 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
7939 23 }
7940
7941 ok:
7942 144408 dir = ndir;
7943 156039 }
7944
7945 535 void enemy::newdir()
7946 {
7947 535 newdir(4,0,spw_none);
7948 535 }
7949
7950 zfix enemy::distance_left()
7951 {
7952 int32_t a2=x.getInt();
7953 int32_t b2=y.getInt();
7954
7955 switch(dir)
7956 {
7957 case up:
7958 return (zfix)(b2&0xF);
7959
7960 case down:
7961 return (zfix)(16-(b2&0xF));
7962
7963 case left:
7964 return (zfix)(a2&0xF);
7965
7966 case right:
7967 return (zfix)(16-(a2&0xF));
7968 }
7969
7970 return (zfix)0;
7971 }
7972
7973 // keeps walking around
7974 120009 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
7975 {
7976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120009 times.
120009 if(slide())
7977 return;
7978
7979
8/12
✓ Branch 0 taken 118643 times.
✓ Branch 1 taken 1366 times.
✓ Branch 2 taken 118643 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 117383 times.
✓ Branch 5 taken 1260 times.
✓ Branch 6 taken 117383 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 117383 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 117383 times.
120009 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
7980 2626 return;
7981
7982
2/2
✓ Branch 0 taken 7006 times.
✓ Branch 1 taken 110377 times.
117383 if(clk3<=0)
7983 {
7984 7006 fix_coords(true);
7985 7006 newdir(newrate,newhoming,special);
7986
7987
1/2
✓ Branch 0 taken 7006 times.
✗ Branch 1 not taken.
7006 if(step==0)
7988 clk3=0;
7989 else
7990 7006 clk3=int32_t(16.0/step);
7991 7006 }
7992
2/2
✓ Branch 0 taken 110364 times.
✓ Branch 1 taken 13 times.
110377 else if(scored)
7993 {
7994 13 dir^=1;
7995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (step != 0) clk3=int32_t(16.0/step)-clk3;
7996 else clk3=32767;
7997 13 }
7998
7999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117383 times.
117383 if (step != 0) --clk3;
8000 117383 move(step);
8001 120009 }
8002
8003 void enemy::constant_walk()
8004 {
8005 constant_walk(4,0,spw_none);
8006 }
8007
8008 6242 int32_t enemy::pos(int32_t newx,int32_t newy)
8009 {
8010 6242 return (newy<<8)+newx;
8011 }
8012
8013 // for variable step rates
8014 93100 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
8015 {
8016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93100 times.
93100 if(slide())
8017 return;
8018
8019
10/14
✓ Branch 0 taken 93100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93100 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90379 times.
✓ Branch 5 taken 2721 times.
✓ Branch 6 taken 88843 times.
✓ Branch 7 taken 1536 times.
✓ Branch 8 taken 77309 times.
✓ Branch 9 taken 11534 times.
✓ Branch 10 taken 77309 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 77309 times.
✗ Branch 13 not taken.
93100 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
8020 15791 return;
8021
8022 77309 zfix dx = (zfix)0;
8023 77309 zfix dy = (zfix)0;
8024
8025
4/9
✓ Branch 0 taken 16696 times.
✓ Branch 1 taken 16882 times.
✓ Branch 2 taken 22128 times.
✓ Branch 3 taken 21603 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
77309 switch(dir)
8026 {
8027 case 8:
8028 case up:
8029 16696 dy-=step;
8030 16696 break;
8031
8032 case 12:
8033 case down:
8034 16882 dy+=step;
8035 16882 break;
8036
8037 case 14:
8038 case left:
8039 22128 dx-=step;
8040 22128 break;
8041
8042 case 10:
8043 case right:
8044 21603 dx+=step;
8045 21603 break;
8046
8047 case 15:
8048 case l_up:
8049 dx-=step;
8050 dy-=step;
8051 break;
8052
8053 case 9:
8054 case r_up:
8055 dx+=step;
8056 dy-=step;
8057 break;
8058
8059 case 13:
8060 case l_down:
8061 dx-=step;
8062 dy+=step;
8063 break;
8064
8065 case 11:
8066 case r_down:
8067 dx+=step;
8068 dy+=step;
8069 break;
8070 }
8071
8072
8/8
✓ Branch 0 taken 35839 times.
✓ Branch 1 taken 41470 times.
✓ Branch 2 taken 4037 times.
✓ Branch 3 taken 31802 times.
✓ Branch 4 taken 2184 times.
✓ Branch 5 taken 1853 times.
✓ Branch 6 taken 75104 times.
✓ Branch 7 taken 2205 times.
77309 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
8073 75125 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
8074 {
8075 2205 fix_coords();
8076 2205 newdir(newrate,newhoming,special);
8077 2205 clk3=pos(x,y);
8078 2205 }
8079
8080 77309 move(step);
8081 93100 }
8082
8083 // pauses for a while after it makes a complete move (to a new square)
8084 3816233 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
8085 {
8086
4/4
✓ Branch 0 taken 23467 times.
✓ Branch 1 taken 3792766 times.
✓ Branch 2 taken 18404 times.
✓ Branch 3 taken 5063 times.
3816233 if(sclk && clk2)
8087 {
8088 5063 clk3=0;
8089 5063 }
8090
8091
10/14
✓ Branch 0 taken 3796259 times.
✓ Branch 1 taken 19974 times.
✓ Branch 2 taken 3796259 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3796259 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3657100 times.
✓ Branch 7 taken 139159 times.
✓ Branch 8 taken 3571514 times.
✓ Branch 9 taken 85586 times.
✓ Branch 10 taken 3571514 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 3571514 times.
3816233 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
8092 {
8093 244719 return;
8094 }
8095
8096
2/2
✓ Branch 0 taken 801448 times.
✓ Branch 1 taken 2770066 times.
3571514 if(clk2>0)
8097 {
8098 801448 --clk2;
8099 801448 return;
8100 }
8101
8102
2/2
✓ Branch 0 taken 124724 times.
✓ Branch 1 taken 2645342 times.
2770066 if(clk3<=0)
8103 {
8104 124724 fix_coords(true);
8105 124724 newdir(newrate,newhoming,special);
8106 124724 clk3=int32_t(16.0/step);
8107
2/2
✓ Branch 0 taken 124716 times.
✓ Branch 1 taken 8 times.
124724 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
8108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124724 times.
124724 if(clk2<0)
8109 {
8110 clk2=0;
8111 }
8112
2/2
✓ Branch 0 taken 18143 times.
✓ Branch 1 taken 106581 times.
124724 else if((zc_oldrand()&15)<newhrate)
8113 {
8114 18143 clk2=haltcnt;
8115 18143 return;
8116 }
8117 106581 }
8118
2/2
✓ Branch 0 taken 2644617 times.
✓ Branch 1 taken 725 times.
2645342 else if(scored)
8119 {
8120 725 dir^=1;
8121
8122
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 724 times.
725 if (step != 0) clk3=int32_t(16.0/step)-clk3;
8123 1 else clk3=32767;
8124 725 }
8125
8126
2/2
✓ Branch 0 taken 11925 times.
✓ Branch 1 taken 2739998 times.
2751923 if (step != 0) --clk3;
8127 2751923 move(step);
8128 3816233 }
8129
8130 // 8-directional movement, aligns to 8 pixels
8131 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
8132 {
8133 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
8134 return;
8135
8136 if(clk3<=0)
8137 {
8138 newdir_8(newrate,newhoming,special);
8139 clk3=int32_t(8.0/step);
8140 if (step == 0) clk3 = 32767;
8141 }
8142
8143 if (step != 0) --clk3;
8144 move(step);
8145 }
8146 // 8-directional movement, aligns to 8 pixels
8147 26981 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
8148 {
8149
6/12
✓ Branch 0 taken 26981 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26981 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26981 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 26981 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 26981 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 26981 times.
26981 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
8150 return;
8151
8152
2/2
✓ Branch 0 taken 24489 times.
✓ Branch 1 taken 2492 times.
26981 if(clk3<=0)
8153 {
8154 2492 newdir_8(newrate,newhoming,special);
8155 2492 clk3=int32_t(8.0/step);
8156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2492 times.
2492 if (step == 0) clk3 = 32767;
8157 2492 }
8158
8159
1/2
✓ Branch 0 taken 26981 times.
✗ Branch 1 not taken.
26981 if (step != 0) --clk3;
8160 26981 move(step);
8161 26981 }
8162
8163 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
8164 {
8165 if(clk<0 || dying || stunclk || watch || frozenclock)
8166 return;
8167
8168 if(!canmove(dir,step,special,false))
8169 clk3=0;
8170
8171 if(clk2>0)
8172 {
8173 --clk2;
8174 return;
8175 }
8176
8177 if(clk3<=0)
8178 {
8179 newdir_8(newrate,newhoming,special);
8180 clk3=newclk;
8181
8182 if(clk2<0)
8183 {
8184 clk2=0;
8185 }
8186 else if((zc_oldrand()&15)<newhrate)
8187 {
8188 newdir_8(newrate,newhoming,special);
8189 clk2=haltcnt;
8190 return;
8191 }
8192 }
8193
8194 --clk3;
8195 move(step);
8196 }
8197
8198 // 8-directional movement, no alignment
8199 1381052 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
8200 {
8201
9/12
✓ Branch 0 taken 1327464 times.
✓ Branch 1 taken 53588 times.
✓ Branch 2 taken 1327464 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1309835 times.
✓ Branch 5 taken 17629 times.
✓ Branch 6 taken 1303448 times.
✓ Branch 7 taken 6387 times.
✓ Branch 8 taken 1303448 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1303448 times.
1381052 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
8202 77604 return;
8203
8204
2/2
✓ Branch 0 taken 1293485 times.
✓ Branch 1 taken 9963 times.
1303448 if(!canmove(dir,step,special,false))
8205 9963 clk3=0;
8206
8207
2/2
✓ Branch 0 taken 1137920 times.
✓ Branch 1 taken 165528 times.
1303448 if(clk3<=0)
8208 {
8209 165528 newdir_8(newrate,newhoming,special);
8210 165528 clk3=newclk;
8211 165528 }
8212
8213 1303448 --clk3;
8214 1303448 move(step);
8215 1381052 }
8216
8217 // same as above but with variable enemy size
8218 33556 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
8219 {
8220
8/12
✓ Branch 0 taken 33054 times.
✓ Branch 1 taken 502 times.
✓ Branch 2 taken 33054 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33054 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33003 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 33003 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 33003 times.
33556 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
8221 553 return;
8222
8223
2/2
✓ Branch 0 taken 32641 times.
✓ Branch 1 taken 362 times.
33003 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
8224 362 clk3=0;
8225
8226
2/2
✓ Branch 0 taken 30775 times.
✓ Branch 1 taken 2228 times.
33003 if(clk3<=0)
8227 {
8228 2228 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
8229 2228 clk3=newclk;
8230 2228 }
8231
8232 33003 --clk3;
8233 33003 move(step);
8234 33556 }
8235
8236 // the variable speed floater movement
8237 // ms is max speed
8238 // ss is step speed
8239 // s is step count
8240 // p is pause count
8241 // g is graduality :)
8242 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
8243 1145685 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8244 {
8245 1145685 ++clk2;
8246 1145685 byte over_pit = overpit(this);
8247
8248
4/4
✓ Branch 0 taken 337594 times.
✓ Branch 1 taken 808091 times.
✓ Branch 2 taken 337327 times.
✓ Branch 3 taken 267 times.
1145685 if(dmisc1 && over_pit) p = 0;
8249
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 24149 times.
✓ Branch 2 taken 367570 times.
✓ Branch 3 taken 704941 times.
✓ Branch 4 taken 49025 times.
1145685 switch(movestatus)
8250 {
8251 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
8252 //! if the conditions prevent it, we jump back to case 2.
8253 case 0: // paused
8254
2/2
✓ Branch 0 taken 23610 times.
✓ Branch 1 taken 539 times.
24149 if(clk2>=p)
8255 {
8256 539 movestatus=1;
8257 539 clk2=0;
8258 539 }
8259
8260 24149 break;
8261
8262 case 1: // speeding up
8263
1/2
✓ Branch 0 taken 367570 times.
✗ Branch 1 not taken.
367570 if (s >= 0)
8264 {
8265
2/2
✓ Branch 0 taken 364585 times.
✓ Branch 1 taken 2985 times.
367570 if(clk2<g*s)
8266 {
8267
2/2
✓ Branch 0 taken 341203 times.
✓ Branch 1 taken 23382 times.
364585 if(!((clk2-1)%g))
8268 23382 step+=ss;
8269 364585 }
8270 else
8271 {
8272 2985 movestatus=2;
8273 2985 clk2=0;
8274 }
8275 367570 }
8276 else
8277 {
8278 if(step < ms)
8279 {
8280 if(!((clk2-1)%g))
8281 {
8282 step+=ss;
8283 if (step >= ms) step = ms;
8284 }
8285 }
8286 else
8287 {
8288 step = ms;
8289 movestatus=2;
8290 clk2=0;
8291 }
8292 }
8293
8294 367570 break;
8295
8296 case 2: // normal
8297 704941 step=ms;
8298
8299
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 704941 times.
✓ Branch 2 taken 128840 times.
✓ Branch 3 taken 576101 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 576101 times.
✓ Branch 6 taken 575331 times.
✓ Branch 7 taken 770 times.
704941 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
8300 {
8301
1/2
✓ Branch 0 taken 770 times.
✗ Branch 1 not taken.
770 if (s >= 0) step=ss*s;
8302 else step=ms;
8303 770 movestatus=3;
8304 770 clk2=0;
8305 770 }
8306
8307 704941 break;
8308
8309 case 3: // slowing down
8310
1/2
✓ Branch 0 taken 49025 times.
✗ Branch 1 not taken.
49025 if (s >= 0)
8311 {
8312
2/2
✓ Branch 0 taken 48425 times.
✓ Branch 1 taken 600 times.
49025 if(clk2<=g*s)
8313 {
8314 { //don't slow down over pits
8315
8316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48425 times.
48425 if(over_pit)
8317 {
8318 if(dmisc1)
8319 {
8320 step=ms;
8321 }
8322 }
8323 else //can slow down
8324 {
8325
4/4
✓ Branch 0 taken 2997 times.
✓ Branch 1 taken 45428 times.
✓ Branch 2 taken 2879 times.
✓ Branch 3 taken 118 times.
48425 if(!(clk2%g) && !dmisc1)
8326 2879 step-=ss;
8327 }
8328 }
8329
8330
8331 48425 }
8332 else
8333 {
8334 //if((moveflags&FLAG_CAN_PITFALL)) //don't check pits if the enemy ignores them
8335 //this doesn't help keese, as they have a z of 0.
8336 //they always nee to run this check.
8337 {
8338
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 600 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
600 if(over_pit &&!dmisc1)
8339 {
8340 --clk2; //if over a pit, don't land, and revert clock change
8341 }
8342 else //can land safely
8343 {
8344 600 movestatus=0;
8345
3/4
✓ Branch 0 taken 378 times.
✓ Branch 1 taken 222 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 378 times.
600 if(dmisc1&&!over_pit)
8346 378 step=0;
8347 600 clk2=0;
8348 }
8349 }
8350
8351 }
8352 49025 }
8353 else
8354 {
8355 if(step > 0)
8356 {
8357 if(over_pit)
8358 {
8359 if(dmisc1)
8360 {
8361 step=ms;
8362 }
8363 }
8364 else //can slow down
8365 {
8366 if(!(clk2%g))
8367 step-=ss;
8368 }
8369 }
8370 else
8371 {
8372 //if((moveflags&FLAG_CAN_PITFALL)) //don't check pits if the enemy ignores them
8373 //this doesn't help keese, as they have a z of 0.
8374 //they always nee to run this check.
8375 if(over_pit)
8376 {
8377 step+=ss; //if over a pit, don't land, and revert clock change
8378 }
8379 else //can land safely
8380 {
8381 movestatus=0;
8382 step=0;
8383 clk2=0;
8384 }
8385 }
8386 }
8387
8388 49025 break;
8389 }
8390
8391
2/2
✓ Branch 0 taken 707156 times.
✓ Branch 1 taken 438529 times.
1145685 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
8392 1145685 }
8393
8394 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
8395 {
8396 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
8397 }
8398
8399 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
8400 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
8401 263605 int32_t enemy::lined_up(int32_t range, bool dir8)
8402 {
8403 263605 int32_t lx = Hero.getX();
8404 263605 int32_t ly = Hero.getY();
8405
8406
2/2
✓ Branch 0 taken 11568 times.
✓ Branch 1 taken 252037 times.
263605 if(abs(lx-int32_t(x))<=range)
8407 {
8408
2/2
✓ Branch 0 taken 4059 times.
✓ Branch 1 taken 7509 times.
11568 if(ly<y)
8409 {
8410 4059 return up;
8411 }
8412
8413 7509 return down;
8414 }
8415
8416
2/2
✓ Branch 0 taken 11998 times.
✓ Branch 1 taken 240039 times.
252037 if(abs(ly-int32_t(y))<=range)
8417 {
8418
2/2
✓ Branch 0 taken 5706 times.
✓ Branch 1 taken 6292 times.
11998 if(lx<x)
8419 {
8420 5706 return left;
8421 }
8422
8423 6292 return right;
8424 }
8425
8426
2/2
✓ Branch 0 taken 47136 times.
✓ Branch 1 taken 192903 times.
240039 if(dir8)
8427 {
8428
2/2
✓ Branch 0 taken 65121 times.
✓ Branch 1 taken 127782 times.
192903 if(abs(lx-x)-abs(ly-y)<=range)
8429 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
8430 {
8431
2/2
✓ Branch 0 taken 30543 times.
✓ Branch 1 taken 34578 times.
65121 if(ly<y)
8432 {
8433
2/2
✓ Branch 0 taken 16733 times.
✓ Branch 1 taken 13810 times.
30543 if(lx<x)
8434 {
8435 16733 return l_up;
8436 }
8437 else
8438 {
8439 13810 return r_up;
8440 }
8441 }
8442 else
8443 {
8444
2/2
✓ Branch 0 taken 17161 times.
✓ Branch 1 taken 17417 times.
34578 if(lx<x)
8445 {
8446 17417 return l_down;
8447 }
8448 else
8449 {
8450 17161 return r_down;
8451 }
8452 }
8453 }
8454 127782 }
8455
8456 174918 return -1;
8457 263605 }
8458
8459 // returns true if Hero is within 'range' pixels of the enemy
8460 8177 bool enemy::HeroInRange(int32_t range)
8461 {
8462 8177 int32_t lx = Hero.getX();
8463 8177 int32_t ly = Hero.getY();
8464
2/2
✓ Branch 0 taken 6817 times.
✓ Branch 1 taken 1360 times.
8177 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
8465 }
8466
8467 // place the enemy in line with Hero (red wizzrobes)
8468 1298 void enemy::place_on_axis(bool floater, bool solid_ok)
8469 {
8470
6/6
✓ Branch 0 taken 1122 times.
✓ Branch 1 taken 176 times.
✓ Branch 2 taken 1164 times.
✓ Branch 3 taken 134 times.
✓ Branch 4 taken 988 times.
✓ Branch 5 taken 176 times.
1298 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
8471
6/6
✓ Branch 0 taken 1046 times.
✓ Branch 1 taken 252 times.
✓ Branch 2 taken 1106 times.
✓ Branch 3 taken 192 times.
✓ Branch 4 taken 854 times.
✓ Branch 5 taken 252 times.
1298 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
8472 1298 int32_t pos2=zc_oldrand()%23;
8473 1298 int32_t tried=0;
8474 1298 bool last_resort,placed=false;
8475
8476
8477 1298 do
8478 {
8479
2/2
✓ Branch 0 taken 1306 times.
✓ Branch 1 taken 978 times.
2284 if(pos2<14)
8480 {
8481 1306 x=(pos2<<4)+16;
8482 1306 y=ly;
8483 1306 }
8484 else
8485 {
8486 978 x=lx;
8487 978 y=((pos2-14)<<4)+16;
8488 }
8489
8490 // Don't commit to a last resort if position is out of bounds.
8491
6/6
✓ Branch 0 taken 2198 times.
✓ Branch 1 taken 86 times.
✓ Branch 2 taken 2095 times.
✓ Branch 3 taken 103 times.
✓ Branch 4 taken 72 times.
✓ Branch 5 taken 2023 times.
2284 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
8492
8493
4/4
✓ Branch 0 taken 1185 times.
✓ Branch 1 taken 1099 times.
✓ Branch 2 taken 2109 times.
✓ Branch 3 taken 924 times.
2284 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
8494 {
8495 // Red Wizzrobes should be able to appear on water, but not other
8496 // solid combos; however, they could appear on solid combos in 2.10,
8497 // and some quests depend on that.
8498
4/4
✓ Branch 0 taken 1213 times.
✓ Branch 1 taken 1995 times.
✓ Branch 2 taken 697 times.
✓ Branch 3 taken 1298 times.
3208 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
8499 3208 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
8500 1298 placed=true;
8501 3208 }
8502
8503
3/6
✓ Branch 0 taken 986 times.
✓ Branch 1 taken 1752 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 986 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2738 if(!placed && tried>=22 && last_resort)
8504 {
8505 placed=true;
8506 }
8507
8508 2738 ++tried;
8509 2738 pos2=(pos2+3)%23;
8510
2/2
✓ Branch 0 taken 986 times.
✓ Branch 1 taken 1752 times.
2738 }
8511 2738 while(!placed);
8512
8513
2/2
✓ Branch 0 taken 1264 times.
✓ Branch 1 taken 488 times.
1752 if(y==ly)
8514 1264 dir=(x<lx)?right:left;
8515 else
8516 488 dir=(y<ly)?down:up;
8517
8518 1752 clk2=tried;
8519 1752 }
8520
8521 5118474 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
8522 {
8523 5118474 int32_t t = o_tile;
8524 5118474 int32_t b = o_tile;
8525
8526 // Darknuts, but also Wizzrobes and Wallmasters
8527
3/4
✓ Branch 0 taken 2013790 times.
✓ Branch 1 taken 2975578 times.
✓ Branch 2 taken 129106 times.
✗ Branch 3 not taken.
5118474 switch(family)
8528 {
8529 case eeWALK:
8530
5/6
✓ Branch 0 taken 244077 times.
✓ Branch 1 taken 2731501 times.
✓ Branch 2 taken 167572 times.
✓ Branch 3 taken 76505 times.
✓ Branch 4 taken 167572 times.
✗ Branch 5 not taken.
2975578 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
8531 {
8532 167572 tile=s_tile;
8533 167572 t=s_tile;
8534 167572 b=s_tile;
8535 167572 }
8536
8537 2975578 break;
8538
8539 case eeTRAP:
8540
4/6
✓ Branch 0 taken 33074 times.
✓ Branch 1 taken 96032 times.
✓ Branch 2 taken 33074 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 33074 times.
129106 if(dummy_int[1] && guysbuf[id].flags2 & eneflag_trp2 && do_animation) // Just to make sure
8541 {
8542 33074 tile=s_tile;
8543 33074 t=s_tile;
8544 33074 b=s_tile;
8545 33074 }
8546
8547 129106 break;
8548
8549 case eeSPINTILE:
8550 if(misc>=96 && do_animation)
8551 {
8552 tile=o_tile+frames*ndir;
8553 t=tile;
8554 }
8555
8556 break;
8557 }
8558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5118474 times.
5118474 if ( do_animation )
8559 {
8560
4/6
✓ Branch 0 taken 105723 times.
✓ Branch 1 taken 5012751 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77420 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4935331 times.
5118474 if(ndir!=0) switch(frames)
8561 {
8562 case 2:
8563 77420 tiledir_small(dir,ndir==4);
8564 77420 break;
8565
8566 case 3:
8567 tiledir_three(dir);
8568 break;
8569
8570 case 4:
8571 4935331 tiledir(dir,ndir==4);
8572 4935331 break;
8573 5012751 }
8574
8575
2/2
✓ Branch 0 taken 2975578 times.
✓ Branch 1 taken 2142896 times.
5118474 if(family==eeWALK)
8576
6/6
✓ Branch 0 taken 2368564 times.
✓ Branch 1 taken 607014 times.
✓ Branch 2 taken 2229009 times.
✓ Branch 3 taken 746569 times.
✓ Branch 4 taken 588571 times.
✓ Branch 5 taken 157998 times.
2975578 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
8577 else
8578 2142896 tile+=f4;
8579 5118474 }
8580 5118474 return b;
8581 }
8582
8583 void enemy::tiledir_three(int32_t ndir)
8584 {
8585 if ( !do_animation ) return;
8586 flip=0;
8587
8588 switch(ndir)
8589 {
8590 case right:
8591 tile+=3;
8592 [[fallthrough]];
8593
8594 case left:
8595 tile+=3;
8596 [[fallthrough]];
8597
8598 case down:
8599 tile+=3;
8600 [[fallthrough]];
8601
8602 case up:
8603 break;
8604 }
8605 }
8606
8607 77420 void enemy::tiledir_small(int32_t ndir, bool fourdir)
8608 {
8609
1/2
✓ Branch 0 taken 77420 times.
✗ Branch 1 not taken.
77420 if ( !do_animation ) return;
8610 77420 flip=0;
8611
8612
4/9
✓ Branch 0 taken 17011 times.
✓ Branch 1 taken 16756 times.
✓ Branch 2 taken 22057 times.
✓ Branch 3 taken 21596 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
77420 switch(ndir)
8613 {
8614 case 8:
8615 case up:
8616 17011 break;
8617
8618 case 12:
8619 case down:
8620 16756 tile+=2;
8621 16756 break;
8622
8623 case 14:
8624 case left:
8625 22057 tile+=4;
8626 22057 break;
8627
8628 case 10:
8629 case right:
8630 21596 tile+=6;
8631 21596 break;
8632
8633 case 9:
8634 case r_up:
8635 if(fourdir)
8636 break;
8637
8638 tile+=10;
8639 break;
8640
8641 case 11:
8642 case r_down:
8643 if(fourdir)
8644 tile+=2;
8645 else
8646 tile+=14;
8647
8648 break;
8649
8650 case 13:
8651 case l_down:
8652 if(fourdir)
8653 tile+=2;
8654 else
8655 tile+=12;
8656
8657 break;
8658
8659 case 15:
8660 case l_up:
8661 if(fourdir)
8662 break;
8663
8664 tile+=8;
8665 break;
8666
8667 default:
8668 //dir=(zc_oldrand()*100)%8;
8669 //tiledir_small(dir);
8670 // flip=zc_oldrand()&3;
8671 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
8672 break;
8673 }
8674 77420 }
8675
8676 5936522 void enemy::tiledir(int32_t ndir, bool fourdir)
8677 {
8678
1/2
✓ Branch 0 taken 5936522 times.
✗ Branch 1 not taken.
5936522 if ( !do_animation ) return;
8679 5936522 flip=0;
8680
8681
9/9
✓ Branch 0 taken 1147150 times.
✓ Branch 1 taken 969640 times.
✓ Branch 2 taken 1392601 times.
✓ Branch 3 taken 1360267 times.
✓ Branch 4 taken 247475 times.
✓ Branch 5 taken 287487 times.
✓ Branch 6 taken 278640 times.
✓ Branch 7 taken 252119 times.
✓ Branch 8 taken 1143 times.
5936522 switch(ndir)
8682 {
8683 case 8:
8684 case up:
8685 1147150 break;
8686
8687 case 12:
8688 case down:
8689 969640 tile+=4;
8690 969640 break;
8691
8692 case 14:
8693 case left:
8694 1392601 tile+=8;
8695 1392601 break;
8696
8697 case 10:
8698 case right:
8699 1360267 tile+=12;
8700 1360267 break;
8701
8702 case 9:
8703 case r_up:
8704
2/2
✓ Branch 0 taken 39457 times.
✓ Branch 1 taken 208018 times.
247475 if(fourdir)
8705 39457 break;
8706 else
8707 208018 tile+=24;
8708
8709 208018 break;
8710
8711 case 11:
8712 case r_down:
8713
2/2
✓ Branch 0 taken 41807 times.
✓ Branch 1 taken 245680 times.
287487 if(fourdir)
8714 41807 tile+=4;
8715 else
8716 245680 tile+=32;
8717
8718 287487 break;
8719
8720 case 13:
8721 case l_down:
8722
2/2
✓ Branch 0 taken 49015 times.
✓ Branch 1 taken 229625 times.
278640 if(fourdir)
8723 49015 tile+=4;
8724 else
8725 229625 tile+=28;
8726
8727 278640 break;
8728
8729 case 15:
8730 case l_up:
8731
2/2
✓ Branch 0 taken 39224 times.
✓ Branch 1 taken 212895 times.
252119 if(fourdir)
8732 39224 break;
8733 else
8734 212895 tile+=20;
8735
8736 212895 break;
8737
8738 default:
8739 //dir=(zc_oldrand()*100)%8;
8740 //tiledir(dir);
8741 // flip=zc_oldrand()&3;
8742 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
8743 1143 break;
8744 }
8745 5936522 }
8746
8747 void enemy::tiledir_big(int32_t ndir, bool fourdir)
8748 {
8749 if ( !do_animation ) return;
8750 flip=0;
8751
8752 switch(ndir)
8753 {
8754 case 8:
8755 case up:
8756 break;
8757
8758 case 12:
8759 case down:
8760 tile+=8;
8761 break;
8762
8763 case 14:
8764 case left:
8765 tile+=40;
8766 break;
8767
8768 case 10:
8769 case right:
8770 tile+=48;
8771 break;
8772
8773 case 9:
8774 case r_up:
8775 if(fourdir)
8776 break;
8777
8778 tile+=88;
8779 break;
8780
8781 case 11:
8782 case r_down:
8783 if(fourdir)
8784 tile+=8;
8785 else
8786 tile+=128;
8787
8788 break;
8789
8790 case 13:
8791 case l_down:
8792 if(fourdir)
8793 tile+=8;
8794 else
8795 tile+=120;
8796
8797 break;
8798
8799 case 15:
8800 case l_up:
8801 if(fourdir)
8802 break;
8803
8804 tile+=80;
8805 break;
8806
8807 default:
8808 //dir=(zc_oldrand()*100)%8;
8809 //tiledir_big(dir);
8810 // flip=zc_oldrand()&3;
8811 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
8812 break;
8813 }
8814 }
8815
8816 11954384 void enemy::update_enemy_frame()
8817 {
8818
2/4
✓ Branch 0 taken 11954384 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11954384 times.
11954384 if(fallclk||drownclk) return;
8819
1/2
✓ Branch 0 taken 11954384 times.
✗ Branch 1 not taken.
11954384 if (!do_animation)
8820 return;
8821
8822
3/4
✓ Branch 0 taken 204335 times.
✓ Branch 1 taken 11750049 times.
✓ Branch 2 taken 204335 times.
✗ Branch 3 not taken.
11954384 if (get_bit(quest_rules,qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
8823
8824
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
11954384 if(get_bit(quest_rules,qr_ANONE_NOANIM)
8825
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11954384 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11954384 && anim == aNONE && family != eeGUY)
8826 return;
8827
2/2
✓ Branch 0 taken 11719394 times.
✓ Branch 1 taken 234990 times.
11954384 int32_t newfrate = zc_max(frate,4);
8828 11954384 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
8829 11954384 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
8830
2/2
✓ Branch 0 taken 7757768 times.
✓ Branch 1 taken 4196616 times.
11954384 int32_t fx = get_bit(quest_rules, qr_NEWENEMYTILES) ? f4 : f2;
8831 11954384 tile = o_tile;
8832 11954384 int32_t basetile = o_tile;
8833 11954384 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
8834 11954384 bool ignore_extend = false;
8835
31/40
✓ Branch 0 taken 67625 times.
✓ Branch 1 taken 2553 times.
✓ Branch 2 taken 5733 times.
✓ Branch 3 taken 829242 times.
✓ Branch 4 taken 95570 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 46675 times.
✓ Branch 7 taken 159557 times.
✓ Branch 8 taken 44498 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1421555 times.
✓ Branch 12 taken 28657 times.
✓ Branch 13 taken 36444 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 199178 times.
✓ Branch 16 taken 396251 times.
✓ Branch 17 taken 105723 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 48711 times.
✓ Branch 20 taken 114069 times.
✓ Branch 21 taken 303915 times.
✓ Branch 22 taken 573051 times.
✓ Branch 23 taken 591092 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 77420 times.
✓ Branch 26 taken 953383 times.
✓ Branch 27 taken 1896504 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 160855 times.
✓ Branch 30 taken 319741 times.
✓ Branch 31 taken 442753 times.
✓ Branch 32 taken 45658 times.
✓ Branch 33 taken 839314 times.
✓ Branch 34 taken 21820 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 1945376 times.
✓ Branch 37 taken 141468 times.
✓ Branch 38 taken 39993 times.
✗ Branch 39 not taken.
11954384 switch(anim)
8836 {
8837
8838 case aDONGO:
8839 {
8840 28657 int32_t fr = stunclk>0 ? 16 : 8;
8841
8842
6/6
✓ Branch 0 taken 27559 times.
✓ Branch 1 taken 1098 times.
✓ Branch 2 taken 3456 times.
✓ Branch 3 taken 24103 times.
✓ Branch 4 taken 1152 times.
✓ Branch 5 taken 2304 times.
28657 if(!dying && clk2>0 && clk2<=64)
8843 {
8844 // bloated
8845
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 512 times.
2304 switch(dir)
8846 {
8847 case up:
8848 512 tile+=9;
8849 512 flip=0;
8850 512 xofs=0;
8851 512 dummy_int[1]=0; //no additional tiles
8852 512 break;
8853
8854 case down:
8855 256 tile+=7;
8856 256 flip=0;
8857 256 xofs=0;
8858 256 dummy_int[1]=0; //no additional tiles
8859 256 break;
8860
8861 case left:
8862 1024 flip=1;
8863 1024 tile+=4;
8864 1024 xofs=16;
8865 1024 dummy_int[1]=1; //second tile is next tile
8866 1024 break;
8867
8868 case right:
8869 512 flip=0;
8870 512 tile+=5;
8871 512 xofs=16;
8872 512 dummy_int[1]=-1; //second tile is previous tile
8873 512 break;
8874 }
8875 2304 }
8876
4/4
✓ Branch 0 taken 1098 times.
✓ Branch 1 taken 25255 times.
✓ Branch 2 taken 568 times.
✓ Branch 3 taken 530 times.
26353 else if(!dying || clk2>19)
8877 {
8878 // normal
8879
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 5442 times.
✓ Branch 2 taken 5800 times.
✓ Branch 3 taken 8935 times.
✓ Branch 4 taken 5646 times.
25823 switch(dir)
8880 {
8881 case up:
8882 5442 tile+=8;
8883 5442 flip=(clk&fr)?1:0;
8884 5442 xofs=0;
8885 5442 dummy_int[1]=0; //no additional tiles
8886 5442 break;
8887
8888 case down:
8889 5800 tile+=6;
8890 5800 flip=(clk&fr)?1:0;
8891 5800 xofs=0;
8892 5800 dummy_int[1]=0; //no additional tiles
8893 5800 break;
8894
8895 case left:
8896 8935 flip=1;
8897 8935 tile+=(clk&fr)?2:0;
8898 8935 xofs=16;
8899 8935 dummy_int[1]=1; //second tile is next tile
8900 8935 break;
8901
8902 case right:
8903 5646 flip=0;
8904 5646 tile+=(clk&fr)?3:1;
8905 5646 xofs=16;
8906 5646 dummy_int[1]=-1; //second tile is next tile
8907 5646 break;
8908 }
8909 25823 }
8910 }
8911 28657 break;
8912
8913 case aNEWDONGO:
8914 {
8915 36444 int32_t fr4=0;
8916
8917
6/6
✓ Branch 0 taken 34806 times.
✓ Branch 1 taken 1638 times.
✓ Branch 2 taken 3360 times.
✓ Branch 3 taken 31446 times.
✓ Branch 4 taken 1120 times.
✓ Branch 5 taken 2240 times.
36444 if(!dying && clk2>0 && clk2<=64)
8918 {
8919 // bloated
8920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2240 times.
2240 if(clk2>=0)
8921 {
8922 2240 fr4=3;
8923 2240 }
8924
8925
2/2
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 1715 times.
2240 if(clk2>=16)
8926 {
8927 1715 fr4=2;
8928 1715 }
8929
8930
2/2
✓ Branch 0 taken 1085 times.
✓ Branch 1 taken 1155 times.
2240 if(clk2>=32)
8931 {
8932 1155 fr4=1;
8933 1155 }
8934
8935
2/2
✓ Branch 0 taken 1645 times.
✓ Branch 1 taken 595 times.
2240 if(clk2>=48)
8936 {
8937 595 fr4=0;
8938 595 }
8939
8940
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 448 times.
✓ Branch 3 taken 576 times.
✓ Branch 4 taken 960 times.
2240 switch(dir)
8941 {
8942 case up:
8943 256 xofs=0;
8944 256 tile+=8+fr4;
8945 256 dummy_int[1]=0; //no additional tiles
8946 256 break;
8947
8948 case down:
8949 448 xofs=0;
8950 448 tile+=12+fr4;
8951 448 dummy_int[1]=0; //no additional tiles
8952 448 break;
8953
8954 case left:
8955 576 tile+=29+(2*fr4);
8956 576 xofs=16;
8957 576 dummy_int[1]=-1; //second tile is previous tile
8958 576 break;
8959
8960 case right:
8961 960 tile+=49+(2*fr4);
8962 960 xofs=16;
8963 960 dummy_int[1]=-1; //second tile is previous tile
8964 960 break;
8965 }
8966 2240 }
8967
4/4
✓ Branch 0 taken 1638 times.
✓ Branch 1 taken 32566 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 715 times.
34204 else if(!dying || clk2>19)
8968 {
8969 // normal
8970
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 6591 times.
✓ Branch 2 taken 7424 times.
✓ Branch 3 taken 9140 times.
✓ Branch 4 taken 10334 times.
33489 switch(dir)
8971 {
8972 case up:
8973 6591 xofs=0;
8974 6591 tile+=((clk&12)>>2);
8975 6591 dummy_int[1]=0; //no additional tiles
8976 6591 break;
8977
8978 case down:
8979 7424 xofs=0;
8980 7424 tile+=4+((clk&12)>>2);
8981 7424 dummy_int[1]=0; //no additional tiles
8982 7424 break;
8983
8984 case left:
8985 9140 tile+=21+((clk&12)>>1);
8986 9140 xofs=16;
8987 9140 dummy_int[1]=-1; //second tile is previous tile
8988 9140 break;
8989
8990 case right:
8991 10334 flip=0;
8992 10334 tile+=41+((clk&12)>>1);
8993 10334 xofs=16;
8994 10334 dummy_int[1]=-1; //second tile is previous tile
8995 10334 break;
8996 }
8997 33489 }
8998 }
8999 36444 break;
9000
9001 case aDONGOBS:
9002 {
9003 int32_t fr4=0;
9004
9005 if(!dying && clk2>0 && clk2<=64)
9006 {
9007 // bloated
9008 if(clk2>=0)
9009 {
9010 fr4=3;
9011 }
9012
9013 if(clk2>=16)
9014 {
9015 fr4=2;
9016 }
9017
9018 if(clk2>=32)
9019 {
9020 fr4=1;
9021 }
9022
9023 if(clk2>=48)
9024 {
9025 fr4=0;
9026 }
9027
9028 switch(dir)
9029 {
9030 case up:
9031 tile+=28+fr4;
9032 yofs+=8;
9033 dummy_int[1]=-20; //second tile change
9034 dummy_int[2]=0; //new xofs change
9035 dummy_int[3]=-16; //new xofs change
9036 break;
9037
9038 case down:
9039 tile+=12+fr4;
9040 yofs-=8;
9041 dummy_int[1]=20; //second tile change
9042 dummy_int[2]=0; //new xofs change
9043 dummy_int[3]=16; //new xofs change
9044 break;
9045
9046 case left:
9047 tile+=49+(2*fr4);
9048 xofs+=8;
9049 dummy_int[1]=-1; //second tile change
9050 dummy_int[2]=-16; //new xofs change
9051 dummy_int[3]=0; //new xofs change
9052 break;
9053
9054 case right:
9055 tile+=69+(2*fr4);
9056 xofs+=8;
9057 dummy_int[1]=-1; //second tile change
9058 dummy_int[2]=-16; //new xofs change
9059 dummy_int[3]=0; //new xofs change
9060 break;
9061 }
9062 }
9063 else if(!dying || clk2>19)
9064 {
9065 // normal
9066 switch(dir)
9067 {
9068 case up:
9069 tile+=20+((clk&24)>>3);
9070 yofs+=8;
9071 dummy_int[1]=-20; //second tile change
9072 dummy_int[2]=0; //new xofs change
9073 dummy_int[3]=-16; //new xofs change
9074 break;
9075
9076 case down:
9077 tile+=4+((clk&24)>>3);
9078 yofs-=8;
9079 dummy_int[1]=20; //second tile change
9080 dummy_int[2]=0; //new xofs change
9081 dummy_int[3]=16; //new xofs change
9082 break;
9083
9084 case left:
9085 xofs=-8;
9086 tile+=40+((clk&24)>>2);
9087 dummy_int[1]=1; //second tile change
9088 dummy_int[2]=16; //new xofs change
9089 dummy_int[3]=0; //new xofs change
9090 break;
9091
9092 case right:
9093 tile+=60+((clk&24)>>2);
9094 xofs=-8;
9095 dummy_int[1]=1; //second tile change
9096 dummy_int[2]=16; //new xofs change
9097 dummy_int[3]=0; //new xofs change
9098 break;
9099 }
9100 }
9101 }
9102 break;
9103
9104 case aWIZZ:
9105 {
9106 // if(d->misc1)
9107
2/2
✓ Branch 0 taken 55336 times.
✓ Branch 1 taken 143842 times.
199178 if(dmisc1)
9108 {
9109
2/2
✓ Branch 0 taken 27886 times.
✓ Branch 1 taken 27450 times.
55336 if(clk&8)
9110 {
9111 27450 ++tile;
9112 27450 }
9113 55336 }
9114 else
9115 {
9116
2/2
✓ Branch 0 taken 71986 times.
✓ Branch 1 taken 71856 times.
143842 if(frame&4)
9117 {
9118 71856 ++tile;
9119 71856 }
9120 }
9121
9122
4/4
✓ Branch 0 taken 33876 times.
✓ Branch 1 taken 62571 times.
✓ Branch 2 taken 67454 times.
✓ Branch 3 taken 35277 times.
199178 switch(dir)
9123 {
9124 case 9:
9125 case 15:
9126 case up:
9127 33876 tile+=2;
9128 33876 break;
9129
9130 case down:
9131 35277 break;
9132
9133 case 13:
9134 case left:
9135 62571 flip=1;
9136 62571 break;
9137
9138 default:
9139 67454 flip=0;
9140 67454 break;
9141 }
9142 }
9143 199178 break;
9144
9145 case aNEWWIZZ:
9146 {
9147 396251 tiledir(dir,true);
9148
9149 // if(d->misc1) //walking wizzrobe
9150
2/2
✓ Branch 0 taken 233508 times.
✓ Branch 1 taken 162743 times.
396251 if(dmisc1) //walking wizzrobe
9151 {
9152
2/2
✓ Branch 0 taken 117335 times.
✓ Branch 1 taken 116173 times.
233508 if(clk&8)
9153 {
9154 116173 tile+=2;
9155 116173 }
9156
9157
2/2
✓ Branch 0 taken 116838 times.
✓ Branch 1 taken 116670 times.
233508 if(clk&4)
9158 {
9159 116670 tile+=1;
9160 116670 }
9161
9162
2/4
✓ Branch 0 taken 233508 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 233508 times.
233508 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
9163 {
9164
2/2
✓ Branch 0 taken 209166 times.
✓ Branch 1 taken 24342 times.
233508 if(dummy_int[1]>0)
9165 {
9166 24342 tile+=40;
9167 24342 }
9168 233508 }
9169 233508 }
9170 else
9171 {
9172
4/4
✓ Branch 0 taken 149210 times.
✓ Branch 1 taken 13533 times.
✓ Branch 2 taken 34665 times.
✓ Branch 3 taken 114545 times.
162743 if(dummy_bool[1]||dummy_bool[2])
9173 {
9174 48198 tile+=20;
9175
9176
2/2
✓ Branch 0 taken 13533 times.
✓ Branch 1 taken 34665 times.
48198 if(dummy_bool[2])
9177 {
9178 34665 tile+=20;
9179 34665 }
9180 48198 }
9181
9182 162743 tile+=((frame>>1)&3);
9183 }
9184 }
9185 396251 break;
9186
9187 case a3FRM:
9188 {
9189
2/2
✓ Branch 0 taken 25554 times.
✓ Branch 1 taken 80169 times.
105723 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
9190 }
9191 105723 break;
9192
9193 case a3FRM4DIR:
9194 {
9195 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
9196 }
9197 break;
9198
9199 case aVIRE:
9200 {
9201
2/2
✓ Branch 0 taken 37532 times.
✓ Branch 1 taken 11179 times.
48711 if(dir==up)
9202 {
9203 11179 tile+=2;
9204 11179 }
9205
9206 48711 tile+=fx;
9207 }
9208 48711 break;
9209
9210 case aROPE:
9211 {
9212 67625 tile+=(1-fx);
9213 67625 flip = dir==left ? 1:0;
9214 }
9215 67625 break;
9216
9217 case aZORA:
9218 {
9219 int32_t dl;
9220
9221
2/2
✓ Branch 0 taken 23518 times.
✓ Branch 1 taken 90551 times.
114069 if(clk<36)
9222 {
9223 23518 dl=clk+5;
9224 23518 goto waves2;
9225 }
9226
9227
2/2
✓ Branch 0 taken 42599 times.
✓ Branch 1 taken 47952 times.
90551 if(clk<36+66)
9228
2/2
✓ Branch 0 taken 23778 times.
✓ Branch 1 taken 18821 times.
42599 tile=(dir==up)?o_tile+1:o_tile;
9229 else
9230 {
9231 47952 dl=clk-36-66;
9232 waves2:
9233 71470 tile=((dl/11)&1)+s_tile;
9234 71470 basetile = s_tile;
9235 }
9236 }
9237 114069 break;
9238
9239 case aNEWZORA:
9240 {
9241 303915 f4=(clk/16)%4;
9242
9243 303915 tiledir(dir,true);
9244 int32_t dl;
9245
9246
4/4
✓ Branch 0 taken 216367 times.
✓ Branch 1 taken 87548 times.
✓ Branch 2 taken 114588 times.
✓ Branch 3 taken 101779 times.
303915 if((clk>35)&&(clk<36+67)) //surfaced
9247 {
9248
4/4
✓ Branch 0 taken 86936 times.
✓ Branch 1 taken 14843 times.
✓ Branch 2 taken 12556 times.
✓ Branch 3 taken 74380 times.
101779 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
9249 {
9250 74380 tile+=80;
9251 74380 } //mouth closed
9252 else
9253 {
9254 27399 tile+=40;
9255 }
9256
9257 101779 tile+=f4;
9258 101779 }
9259 else
9260 {
9261
2/2
✓ Branch 0 taken 87548 times.
✓ Branch 1 taken 114588 times.
202136 if(clk<36)
9262 {
9263 87548 dl=clk+5;
9264 87548 }
9265 else
9266 {
9267 114588 dl=clk-36-66;
9268 }
9269
9270 202136 tile+=((dl/5)&3);
9271 }
9272 }
9273 303915 break;
9274
9275 case a4FRM4EYE:
9276 case a2FRM4EYE:
9277 case a4FRM8EYE:
9278 case a4FRM8EYEB: //big version
9279 case a4FRM4EYEB:
9280 {
9281 44498 tilerows = 2;
9282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44498 times.
44498 int fakex = x + 8*(zc_max(1,txsz)-1);
9283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44498 times.
44498 int fakey = y + 8*(zc_max(1,tysz)-1);
9284 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9285 44498 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
9286 44498 int32_t lookat=zc_oldrand()&15;
9287
9288
4/4
✓ Branch 0 taken 15290 times.
✓ Branch 1 taken 29208 times.
✓ Branch 2 taken 7702 times.
✓ Branch 3 taken 7588 times.
44498 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
9289 {
9290 7588 lookat=l_down;
9291 7588 }
9292
4/4
✓ Branch 0 taken 12668 times.
✓ Branch 1 taken 24242 times.
✓ Branch 2 taken 7702 times.
✓ Branch 3 taken 4966 times.
36910 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
9293 {
9294 4966 lookat=down;
9295 4966 }
9296
4/4
✓ Branch 0 taken 13062 times.
✓ Branch 1 taken 18882 times.
✓ Branch 2 taken 7702 times.
✓ Branch 3 taken 5360 times.
31944 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
9297 {
9298 5360 lookat=r_down;
9299 5360 }
9300
4/4
✓ Branch 0 taken 12986 times.
✓ Branch 1 taken 13598 times.
✓ Branch 2 taken 7702 times.
✓ Branch 3 taken 5284 times.
26584 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
9301 {
9302 5284 lookat=right;
9303 5284 }
9304
4/4
✓ Branch 0 taken 9974 times.
✓ Branch 1 taken 11326 times.
✓ Branch 2 taken 7702 times.
✓ Branch 3 taken 2272 times.
21300 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
9305 {
9306 2272 lookat=r_up;
9307 2272 }
9308
4/4
✓ Branch 0 taken 10028 times.
✓ Branch 1 taken 9000 times.
✓ Branch 2 taken 7702 times.
✓ Branch 3 taken 2326 times.
19028 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
9309 {
9310 2326 lookat=up;
9311 2326 }
9312
4/4
✓ Branch 0 taken 9782 times.
✓ Branch 1 taken 6920 times.
✓ Branch 2 taken 7702 times.
✓ Branch 3 taken 2080 times.
16702 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
9313 {
9314 2080 lookat=l_up;
9315 2080 }
9316 else
9317 {
9318 14622 lookat=left;
9319 }
9320
9321 44498 int32_t dir2 = dir;
9322 44498 dir = lookat;
9323
3/6
✓ Branch 0 taken 44498 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 44498 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 44498 times.
44498 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
9324 else
9325 {
9326 tiledir_big(dir,(anim == a4FRM4EYEB));
9327 tile+=2*f4;
9328 ignore_extend = true;
9329 }
9330 44498 dir = dir2;
9331 }
9332 44498 break;
9333
9334 case aFLIP:
9335 {
9336 573051 flip = f2&1;
9337 }
9338 573051 break;
9339
9340 case a2FRM:
9341 {
9342 591092 tile += (1-f2);
9343 }
9344 591092 break;
9345
9346 case a2FRMB:
9347 {
9348 tile+= 2*(1-f2);
9349 ignore_extend = true;
9350 }
9351 break;
9352
9353 case a2FRM4DIR:
9354 {
9355 77420 basetile = n_frame_n_dir(2, 4, f2&1);
9356 }
9357 77420 break;
9358
9359 case a4FRM4DIRF:
9360 {
9361 953383 basetile = n_frame_n_dir(4,4,f4);
9362
9363
2/2
✓ Branch 0 taken 566902 times.
✓ Branch 1 taken 386481 times.
953383 if(clk2>0) //stopped to fire
9364 {
9365 386481 tile+=20;
9366
9367
2/2
✓ Branch 0 taken 177437 times.
✓ Branch 1 taken 209044 times.
386481 if(clk2<17) //firing
9368 {
9369 209044 tile+=20;
9370 209044 }
9371 386481 }
9372 }
9373 953383 break;
9374
9375 case a4FRM4DIR:
9376 {
9377 1896504 basetile = n_frame_n_dir(4,4,f4);
9378 }
9379 1896504 break;
9380
9381 case a4FRM8DIRF:
9382 {
9383 tilerows = 2;
9384 basetile = n_frame_n_dir(4,8,f4);
9385
9386 if(clk2>0) //stopped to fire
9387 {
9388 tile+=40;
9389
9390 if(clk2<17) //firing
9391 {
9392 tile+=40;
9393 }
9394 }
9395 }
9396 break;
9397
9398 case a4FRM8DIRB:
9399 case a4FRM8DIRFB:
9400 {
9401 tilerows = 2;
9402 tiledir_big(dir,false);
9403 tile+=2*f4;
9404 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
9405 {
9406 tile+=80;
9407
9408 if(clk2<17) //firing
9409 {
9410 tile+=80;
9411 }
9412 }
9413 ignore_extend = true;
9414 }
9415 break;
9416
9417 case a4FRM4DIRB:
9418 case a4FRM4DIRFB:
9419 {
9420 tilerows = 2;
9421 tiledir_big(dir,true);
9422 tile+=2*f4;
9423 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
9424 {
9425 tile+=40;
9426
9427 if(clk2<17) //firing
9428 {
9429 tile+=40;
9430 }
9431 }
9432 ignore_extend = true;
9433 }
9434 break;
9435
9436 case aOCTO:
9437 {
9438
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 35999 times.
✓ Branch 2 taken 39336 times.
✓ Branch 3 taken 47224 times.
✓ Branch 4 taken 38296 times.
160855 switch(dir)
9439 {
9440 case up:
9441 35999 flip = 2;
9442 35999 break;
9443
9444 case down:
9445 39336 flip = 0;
9446 39336 break;
9447
9448 case left:
9449 47224 flip = 0;
9450 47224 tile += 2;
9451 47224 break;
9452
9453 case right:
9454 38296 flip = 1;
9455 38296 tile += 2;
9456 38296 break;
9457 }
9458
9459 160855 tile+=f2;
9460 }
9461 160855 break;
9462
9463 case aWALK:
9464 {
9465
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 61404 times.
✓ Branch 2 taken 71505 times.
✓ Branch 3 taken 92937 times.
✓ Branch 4 taken 93895 times.
319741 switch(dir)
9466 {
9467 case up:
9468 61404 tile+=3;
9469 61404 flip = f2;
9470 61404 break;
9471
9472 case down:
9473 71505 tile+=2;
9474 71505 flip = f2;
9475 71505 break;
9476
9477 case left:
9478 92937 flip=1;
9479 92937 tile += f2;
9480 92937 break;
9481
9482 case right:
9483 93895 flip=0;
9484 93895 tile += f2;
9485 93895 break;
9486 }
9487 }
9488 319741 break;
9489
9490 case aDWALK:
9491 {
9492
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 442753 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
442753 if((get_bit(quest_rules,qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
9493 {
9494 tile=s_tile;
9495 basetile = s_tile;
9496 }
9497
9498
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 91056 times.
✓ Branch 2 taken 91679 times.
✓ Branch 3 taken 128932 times.
✓ Branch 4 taken 131086 times.
442753 switch(dir)
9499 {
9500 case up:
9501 91056 tile+=2;
9502 91056 flip=f2;
9503 91056 break;
9504
9505 case down:
9506 91679 flip=0;
9507 91679 tile+=(1-f2);
9508 91679 break;
9509
9510 case left:
9511 128932 flip=1;
9512 128932 tile+=(3+f2);
9513 128932 break;
9514
9515 case right:
9516 131086 flip=0;
9517 131086 tile+=(3+f2);
9518 131086 break;
9519 }
9520 }
9521 442753 break;
9522
9523 case aTEK:
9524 {
9525
2/2
✓ Branch 0 taken 26984 times.
✓ Branch 1 taken 18674 times.
45658 if(misc==0)
9526 {
9527 18674 tile += f2;
9528 18674 }
9529
2/2
✓ Branch 0 taken 14663 times.
✓ Branch 1 taken 12321 times.
26984 else if(misc!=1)
9530 {
9531 12321 ++tile;
9532 12321 }
9533 }
9534 45658 break;
9535
9536 case aNEWTEK:
9537 {
9538
2/2
✓ Branch 0 taken 222144 times.
✓ Branch 1 taken 617170 times.
839314 if(step<0) //up
9539 {
9540
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 107406 times.
✓ Branch 2 taken 114738 times.
222144 switch(clk3)
9541 {
9542 case left:
9543 107406 flip=0;
9544 107406 tile+=20;
9545 107406 break;
9546
9547 case right:
9548 114738 flip=0;
9549 114738 tile+=24;
9550 114738 break;
9551 }
9552 222144 }
9553
2/2
✓ Branch 0 taken 28247 times.
✓ Branch 1 taken 588923 times.
617170 else if(step==0)
9554 {
9555
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 20536 times.
✓ Branch 2 taken 7711 times.
28247 switch(clk3)
9556 {
9557 case left:
9558 20536 flip=0;
9559 20536 tile+=8;
9560 20536 break;
9561
9562 case right:
9563 7711 flip=0;
9564 7711 tile+=12;
9565 7711 break;
9566 }
9567 28247 } //down
9568 else
9569 {
9570
3/3
✓ Branch 0 taken 26486 times.
✓ Branch 1 taken 283380 times.
✓ Branch 2 taken 279057 times.
588923 switch(clk3)
9571 {
9572 case left:
9573 283380 flip=0;
9574 283380 tile+=28;
9575 283380 break;
9576
9577 case right:
9578 279057 flip=0;
9579 279057 tile+=32;
9580 279057 break;
9581 }
9582 }
9583
9584
2/2
✓ Branch 0 taken 554427 times.
✓ Branch 1 taken 284887 times.
839314 if(misc==0)
9585 {
9586 284887 tile+=f4;
9587 284887 }
9588
2/2
✓ Branch 0 taken 262665 times.
✓ Branch 1 taken 291762 times.
554427 else if(misc!=1)
9589 {
9590 291762 tile+=2;
9591 291762 }
9592 }
9593 839314 break;
9594
9595 case aARMOS:
9596 {
9597
2/2
✓ Branch 0 taken 732 times.
✓ Branch 1 taken 1821 times.
2553 if(!fading)
9598 {
9599 1821 tile += fx;
9600
9601
2/2
✓ Branch 0 taken 1151 times.
✓ Branch 1 taken 670 times.
1821 if(dir==up)
9602 670 tile += 2;
9603 1821 }
9604 }
9605 2553 break;
9606
9607 case aARMOS4:
9608 {
9609
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 617 times.
✓ Branch 2 taken 3083 times.
✓ Branch 3 taken 1106 times.
✓ Branch 4 taken 927 times.
5733 switch(dir)
9610 {
9611 case up:
9612 617 flip=0;
9613 617 break;
9614
9615 case down:
9616 3083 flip=0;
9617 3083 tile+=4;
9618 3083 break;
9619
9620 case left:
9621 1106 flip=0;
9622 1106 tile+=8;
9623 1106 break;
9624
9625 case right:
9626 927 flip=0;
9627 927 tile+=12;
9628 927 break;
9629 }
9630
9631
2/2
✓ Branch 0 taken 2623 times.
✓ Branch 1 taken 3110 times.
5733 if(!fading)
9632 {
9633 3110 tile+=f4;
9634 3110 }
9635 }
9636 5733 break;
9637
9638 case aGHINI:
9639 {
9640
3/4
✓ Branch 0 taken 4515 times.
✓ Branch 1 taken 5782 times.
✓ Branch 2 taken 11523 times.
✗ Branch 3 not taken.
21820 switch(dir)
9641 {
9642 case 8:
9643 case 9:
9644 case up:
9645 4515 ++tile;
9646 4515 flip=0;
9647 4515 break;
9648
9649 case 15:
9650 ++tile;
9651 flip=1;
9652 break;
9653
9654 case 10:
9655 case 11:
9656 case right:
9657 5782 flip=1;
9658 5782 break;
9659
9660 default:
9661 11523 flip=0;
9662 11523 break;
9663 }
9664 }
9665 21820 break;
9666
9667 case a2FRMPOS:
9668 {
9669 829242 tile+=posframe;
9670 }
9671 829242 break;
9672
9673 case a4FRMPOS4DIR:
9674 {
9675 95570 basetile = n_frame_n_dir(4,4,0);
9676 // tile+=f2;
9677 95570 tile+=posframe;
9678 }
9679 95570 break;
9680
9681 case a4FRMPOS4DIRF:
9682 {
9683 basetile = n_frame_n_dir(4,4,0);
9684
9685 if(clk2>0) //stopped to fire
9686 {
9687 tile+=20;
9688
9689 if(clk2<17) //firing
9690 {
9691 tile+=20;
9692 }
9693 }
9694
9695 // tile+=f2;
9696 tile+=posframe;
9697 }
9698 break;
9699
9700 case a4FRMPOS8DIR:
9701 {
9702 1945376 tilerows = 2;
9703 1945376 int32_t n = tile;
9704 1945376 basetile = n_frame_n_dir(4,8,0);
9705 // tile+=f2;
9706 1945376 tile+=posframe;
9707 }
9708 1945376 break;
9709
9710 case a4FRMPOS8DIRF:
9711 {
9712 tilerows = 2;
9713 basetile = n_frame_n_dir(4,8,0);
9714
9715 if(clk2>0) //stopped to fire
9716 {
9717 tile+=40;
9718
9719 if(clk2<17) //firing
9720 {
9721 tile+=40;
9722 }
9723 }
9724
9725 tile+=posframe;
9726 }
9727 break;
9728
9729 case aNEWLEV:
9730 {
9731 141468 tiledir(dir,true);
9732
9733
4/5
✓ Branch 0 taken 41275 times.
✓ Branch 1 taken 25438 times.
✓ Branch 2 taken 10006 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64749 times.
141468 switch(misc)
9734 {
9735 case -1:
9736 case 0:
9737 41275 return;
9738
9739 case 1:
9740
9741 // case 5: cs = d->misc2; break;
9742 case 5:
9743 25438 cs = dmisc2;
9744 25438 break;
9745
9746 case 2:
9747 case 4:
9748 10006 tile += 20;
9749 10006 break;
9750
9751 case 3:
9752 64749 tile += 40;
9753 64749 break;
9754 }
9755
9756 100193 tile+=f4;
9757 }
9758 100193 break;
9759
9760 case aLEV:
9761 {
9762 39993 f4 = ((clk/5)&1);
9763
9764
4/5
✓ Branch 0 taken 19248 times.
✓ Branch 1 taken 4577 times.
✓ Branch 2 taken 2268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13900 times.
39993 switch(misc)
9765 {
9766 case -1:
9767 case 0:
9768 19248 return;
9769
9770 case 1:
9771
9772 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
9773 case 5:
9774 4577 tile += (f2) ? 1 : 0;
9775 4577 cs = dmisc2;
9776 4577 break;
9777
9778 case 2:
9779 case 4:
9780 2268 tile += 2;
9781 2268 break;
9782
9783 case 3:
9784 13900 tile += (f4) ? 4 : 3;
9785 13900 break;
9786 }
9787 }
9788 20745 break;
9789
9790 case aWALLM:
9791 {
9792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46675 times.
46675 if(!dummy_bool[1])
9793 {
9794 46675 tile += f2;
9795 46675 }
9796 }
9797 46675 break;
9798
9799 case aNEWWALLM:
9800 {
9801 159557 int32_t tempdir=0;
9802
9803
4/4
✓ Branch 0 taken 24036 times.
✓ Branch 1 taken 16474 times.
✓ Branch 2 taken 5177 times.
✓ Branch 3 taken 113870 times.
159557 switch(misc)
9804 {
9805 case 1:
9806 case 2:
9807 16474 tempdir=clk3;
9808 16474 break;
9809
9810 case 3:
9811 case 4:
9812 case 5:
9813 24036 tempdir=dir;
9814 24036 break;
9815
9816 case 6:
9817 case 7:
9818 5177 tempdir=clk3^1;
9819 5177 break;
9820 }
9821
9822 159557 tiledir(tempdir,true);
9823
9824
2/2
✓ Branch 0 taken 578 times.
✓ Branch 1 taken 158979 times.
159557 if(!dummy_bool[1])
9825 {
9826 158979 tile+=f4;
9827 158979 }
9828 }
9829 159557 break;
9830
9831 case a4FRMNODIR:
9832 {
9833 tile+=f4;
9834 }
9835 break;
9836
9837 } // switch(d->anim)
9838
9839 // flashing
9840 // if(d->flags2 & guy_flashing)
9841
2/2
✓ Branch 0 taken 11578201 times.
✓ Branch 1 taken 315660 times.
11893861 if(flags2 & guy_flashing)
9842 {
9843 315660 cs = (frame&3) + 6;
9844 315660 }
9845
9846
2/2
✓ Branch 0 taken 11861747 times.
✓ Branch 1 taken 32114 times.
11893861 if(flags2&guy_transparent)
9847 {
9848 32114 drawstyle=1;
9849 32114 }
9850
9851 11893861 int32_t change = tile-basetile;
9852
9853
3/6
✓ Branch 0 taken 111569 times.
✓ Branch 1 taken 11782292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 111569 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11893861 if(extend > 2 && (!ignore_extend || get_bit(quest_rules, qr_BROKEN_BIG_ENEMY_ANIMATION)))
9854 {
9855
1/2
✓ Branch 0 taken 111569 times.
✗ Branch 1 not taken.
111569 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
9856 {
9857 111569 tile=basetile+txsz*change;
9858 111569 }
9859 else
9860 {
9861 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
9862 }
9863 111569 }
9864 else
9865 {
9866 11782292 tile=basetile+change;
9867 }
9868 11954384 }
9869
9870 35890 int32_t wpnsfx(int32_t wpn)
9871 {
9872
5/6
✓ Branch 0 taken 15896 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 12256 times.
✓ Branch 3 taken 5313 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2230 times.
35890 switch(wpn)
9873 {
9874 case ewFireTrail:
9875 case ewFlame:
9876 case ewFlame2Trail:
9877 case ewFlame2:
9878 15896 return WAV_FIRE;
9879
9880 case ewWind:
9881 case ewMagic:
9882 195 return WAV_WAND;
9883
9884 case ewIce:
9885 return WAV_ZN1ICE;
9886
9887 case ewRock:
9888
2/2
✓ Branch 0 taken 2142 times.
✓ Branch 1 taken 88 times.
2230 if(get_bit(quest_rules,qr_MORESOUNDS)) return WAV_ZN1ROCK;
9889 2142 break;
9890
9891 case ewFireball2:
9892 case ewFireball:
9893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12256 times.
12256 if(get_bit(quest_rules,qr_MORESOUNDS)) return WAV_ZN1FIREBALL;
9894 12256 }
9895
9896 19711 return -1;
9897 35890 }
9898
9899 21664988 int32_t enemy::run_script(int32_t mode)
9900 {
9901
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 21664988 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
21664988 if(switch_hooked && !get_bit(quest_rules, qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
9902
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 21664988 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
21664988 if (script <= 0 || !doscript || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
9903 21664988 return RUNSCRIPT_OK;
9904 int32_t ret = RUNSCRIPT_OK;
9905 alloc_scriptmem();
9906 switch(mode)
9907 {
9908 case MODE_NORMAL:
9909 return ZScriptVersion::RunScript(SCRIPT_NPC, script, getUID());
9910 case MODE_WAITDRAW:
9911 if(waitdraw)
9912 {
9913 ret = ZScriptVersion::RunScript(SCRIPT_NPC, script, getUID());
9914 waitdraw = 0;
9915 }
9916 break;
9917 }
9918 return ret;
9919 21664988 }
9920
9921 /********************************/
9922 /********* Guy Class **********/
9923 /********************************/
9924
9925 // good guys, fires, fairy, and other non-enemies
9926 // based on enemy class b/c guys in dungeons act sort of like enemies
9927 // also easier to manage all the guys this way
9928 1450 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
9929 1450 {
9930 725 mainguy=mg;
9931 725 canfreeze=false;
9932 725 dir=down;
9933
3/6
✓ Branch 0 taken 725 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 725 times.
✓ Branch 4 taken 725 times.
✗ Branch 5 not taken.
725 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9934 725 hxofs=2;
9935 725 hzsz=8;
9936 725 hxsz=12;
9937 725 hysz=17;
9938
9939
10/12
✓ Branch 0 taken 725 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 725 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 262 times.
✓ Branch 5 taken 463 times.
✓ Branch 6 taken 253 times.
✓ Branch 7 taken 9 times.
✓ Branch 8 taken 85 times.
✓ Branch 9 taken 168 times.
✓ Branch 10 taken 9 times.
✓ Branch 11 taken 76 times.
725 if(!superman && (!isdungeon() || id==gFAIRY || id==gFIRE || id==gZELDA))
9940 {
9941 649 superman = 1;
9942 649 hxofs=1000;
9943 649 }
9944 725 }
9945
9946 197070 bool guy::animate(int32_t index)
9947 {
9948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 197070 times.
197070 if(switch_hooked) return enemy::animate(index);
9949
6/6
✓ Branch 0 taken 72409 times.
✓ Branch 1 taken 124661 times.
✓ Branch 2 taken 544 times.
✓ Branch 3 taken 71865 times.
✓ Branch 4 taken 248 times.
✓ Branch 5 taken 296 times.
197070 if(mainguy && clk==0 && misc==0)
9950 {
9951 296 setupscreen();
9952 296 misc = 1;
9953 296 }
9954
9955
4/4
✓ Branch 0 taken 72409 times.
✓ Branch 1 taken 124661 times.
✓ Branch 2 taken 72306 times.
✓ Branch 3 taken 103 times.
197070 if(mainguy && fadeclk==0)
9956 103 return true;
9957
9958 196967 hp=256; // good guys never die...
9959
9960
4/4
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 196916 times.
✓ Branch 2 taken 49 times.
✓ Branch 3 taken 2 times.
196967 if(hclk && !clk2)
9961 {
9962 // but if they get hit...
9963 2 ++clk2; // only do this once
9964
9965
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 if(!get_bit(quest_rules,qr_NOGUYFIRES))
9966 {
9967 1 addenemy(BSZ?64:72,68,eSHOOTFBALL,0);
9968 1 addenemy(BSZ?176:168,68,eSHOOTFBALL,0);
9969 1 }
9970 2 }
9971
9972 196967 return enemy::animate(index);
9973 197070 }
9974
9975 198355 void guy::draw(BITMAP *dest)
9976 {
9977 198355 update_enemy_frame();
9978
9979
6/6
✓ Branch 0 taken 73564 times.
✓ Branch 1 taken 124791 times.
✓ Branch 2 taken 7032 times.
✓ Branch 3 taken 66532 times.
✓ Branch 4 taken 3515 times.
✓ Branch 5 taken 3517 times.
198355 if(!mainguy || fadeclk<0 || fadeclk&1)
9980 194838 enemy::draw(dest);
9981 198355 }
9982
9983 /*******************************/
9984 /********* Enemies *********/
9985 /*******************************/
9986
9987 74 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9988 74 {
9989 37 clk4=0;
9990 37 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
9991 // Spawn type
9992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(flags & guy_fadeflicker)
9993 {
9994 clk=0;
9995 superman = 1;
9996 fading=fade_flicker;
9997 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9998 dir=down;
9999
10000 if(!canmove(down,(zfix)8,spw_none,false))
10001 clk3=int32_t(13.0/step);
10002 }
10003
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 else if(flags & guy_fadeinstant)
10004 {
10005 clk=0;
10006 }
10007 37 SIZEflags = d->SIZEflags;
10008
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
37 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10009 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10010 // al_trace("Enemy txsz:%i\n", txsz);
10011
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
37 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10012
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
37 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10013
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
37 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10014
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
37 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10015
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10016
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10017 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10018
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
37 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10020 {
10021 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10022 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10023 }
10024
10025
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
37 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) d->zofs = (int32_t)zofs;
10026 37 }
10027
10028 16998 bool eFire::animate(int32_t index)
10029 {
10030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16998 times.
16998 if(switch_hooked) return enemy::animate(index);
10031
2/4
✓ Branch 0 taken 16998 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16998 times.
16998 if(fallclk||drownclk) return enemy::animate(index);
10032
2/2
✓ Branch 0 taken 16941 times.
✓ Branch 1 taken 57 times.
16998 if(fading)
10033 {
10034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if(++clk4 > 60)
10035 {
10036 clk4=0;
10037 superman=0;
10038 fading=0;
10039
10040 if(flags2&cmbflag_armos && z==0 && fakez==0)
10041 removearmos(x,y,ffcactivated);
10042
10043 clk2=0;
10044
10045 if(!canmove(down,(zfix)8,spw_none,false))
10046 {
10047 dir=0;
10048 y = y.getInt() & 0xF0;
10049 }
10050
10051 return Dead(index);
10052 }
10053
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
57 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
10054 removearmos(x,y,ffcactivated);
10055 57 }
10056
10057 16998 return enemy::animate(index);
10058 16998 }
10059
10060 35718 void eFire::draw(BITMAP *dest)
10061 {
10062 35718 update_enemy_frame();
10063 35718 enemy::draw(dest);
10064 35718 }
10065
10066 80 int32_t eFire::takehit(weapon *w)
10067 {
10068 80 int32_t wpnId = w->id;
10069 80 int32_t wpnDir = w->dir;
10070
10071
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if(wpnId==wHammer && shield && (flags & guy_bkshield)
10072 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
10073 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
10074 {
10075 shield = false;
10076 flags &= ~(inv_left|inv_right|inv_back|inv_front);
10077
10078 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10079 o_tile=s_tile;
10080 }
10081
10082 80 int32_t ret = enemy::takehit(w);
10083 80 return ret;
10084 }
10085
10086 void eFire::break_shield()
10087 {
10088 if(!shield)
10089 return;
10090
10091 flags&=~(inv_front | inv_back | inv_left | inv_right);
10092 shield=false;
10093
10094 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10095 o_tile=s_tile;
10096 }
10097
10098 588 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10099 588 {
10100 //zprint2("npct other::other\n");
10101 294 clk4=0;
10102 294 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
10103
10104 // Spawn type
10105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
294 if(flags & guy_fadeflicker)
10106 {
10107 clk=0;
10108 superman = 1;
10109 fading=fade_flicker;
10110 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10111 dir=down;
10112
10113 if(!canmove(down,(zfix)8,spw_none,false))
10114 clk3=int32_t(13.0/step);
10115 }
10116
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 else if(flags & guy_fadeinstant)
10117 {
10118 clk=0;
10119 }
10120 294 SIZEflags = d->SIZEflags;
10121
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
294 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10122 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10123 // al_trace("Enemy txsz:%i\n", txsz);
10124
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
294 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10125
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
294 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10126
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
294 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10127
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
294 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10128
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10129
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10130 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10131
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
294 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
294 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10133 {
10134 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10135 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10136 }
10137
10138
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
294 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10139 294 }
10140
10141 104615 bool eOther::animate(int32_t index)
10142 {
10143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104615 times.
104615 if(switch_hooked) return enemy::animate(index);
10144
2/4
✓ Branch 0 taken 104615 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104615 times.
104615 if(fallclk||drownclk) return enemy::animate(index);
10145 //zprint2("npct other::animate\n");
10146
1/2
✓ Branch 0 taken 104615 times.
✗ Branch 1 not taken.
104615 if(fading)
10147 {
10148 if(++clk4 > 60)
10149 {
10150 clk4=0;
10151 superman=0;
10152 fading=0;
10153
10154 if(flags2&cmbflag_armos && z==0 && fakez==0)
10155 removearmos(x,y,ffcactivated);
10156
10157 clk2=0;
10158
10159 if(!canmove(down,(zfix)8,spw_none,false))
10160 {
10161 dir=0;
10162 y = y.getInt() & 0xF0;
10163 }
10164
10165 return Dead(index);
10166 }
10167 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
10168 removearmos(x,y,ffcactivated);
10169 }
10170
10171 104615 return enemy::animate(index);
10172 104615 }
10173
10174 105622 void eOther::draw(BITMAP *dest)
10175 {
10176 105622 update_enemy_frame();
10177 105622 enemy::draw(dest);
10178 105622 }
10179
10180 723 int32_t eOther::takehit(weapon *w)
10181 {
10182 723 int32_t wpnId = w->id;
10183 723 int32_t wpnDir = w->dir;
10184
10185
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 723 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
723 if(wpnId==wHammer && shield && (flags & guy_bkshield)
10186 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
10187 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
10188 {
10189 shield = false;
10190 flags &= ~(inv_left|inv_right|inv_back|inv_front);
10191
10192 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10193 o_tile=s_tile;
10194 }
10195
10196 723 int32_t ret = enemy::takehit(w);
10197 723 return ret;
10198 }
10199
10200 void eOther::break_shield()
10201 {
10202 if(!shield)
10203 return;
10204
10205 flags&=~(inv_front | inv_back | inv_left | inv_right);
10206 shield=false;
10207
10208 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10209 o_tile=s_tile;
10210 }
10211
10212
10213 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10214 {
10215 clk4=0;
10216 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
10217
10218 // Spawn type
10219 if(flags & guy_fadeflicker)
10220 {
10221 clk=0;
10222 superman = 1;
10223 fading=fade_flicker;
10224 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10225 dir=down;
10226
10227 if(!canmove(down,(zfix)8,spw_none,false))
10228 clk3=int32_t(13.0/step);
10229 }
10230 else if(flags & guy_fadeinstant)
10231 {
10232 clk=0;
10233 }
10234 SIZEflags = d->SIZEflags;
10235 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10236 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10237 // al_trace("Enemy txsz:%i\n", txsz);
10238 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10239 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10240 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10241 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10242 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10243 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10244 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10245 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10246 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10247 {
10248 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10249 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10250 }
10251
10252 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10253 }
10254
10255 bool eScript::animate(int32_t index)
10256 {
10257 if(switch_hooked) return enemy::animate(index);
10258 if(fallclk||drownclk) return enemy::animate(index);
10259 if(fading)
10260 {
10261 if(++clk4 > 60)
10262 {
10263 clk4=0;
10264 superman=0;
10265 fading=0;
10266
10267 if(flags2&cmbflag_armos && z==0 && fakez==0)
10268 removearmos(x,y,ffcactivated);
10269
10270 clk2=0;
10271
10272 if(!canmove(down,(zfix)8,spw_none,false))
10273 {
10274 dir=0;
10275 y = y.getInt() & 0xF0;
10276 }
10277
10278 return Dead(index);
10279 }
10280 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
10281 removearmos(x,y,ffcactivated);
10282 }
10283
10284 return enemy::animate(index);
10285 }
10286
10287 void eScript::draw(BITMAP *dest)
10288 {
10289 update_enemy_frame();
10290 enemy::draw(dest);
10291 }
10292
10293 int32_t eScript::takehit(weapon *w)
10294 {
10295 int32_t wpnId = w->id;
10296 int32_t wpnDir = w->dir;
10297
10298 if(wpnId==wHammer && shield && (flags & guy_bkshield)
10299 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
10300 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
10301 {
10302 shield = false;
10303 flags &= ~(inv_left|inv_right|inv_back|inv_front);
10304
10305 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10306 o_tile=s_tile;
10307 }
10308
10309 int32_t ret = enemy::takehit(w);
10310 return ret;
10311 }
10312
10313 void eScript::break_shield()
10314 {
10315 if(!shield)
10316 return;
10317
10318 flags&=~(inv_front | inv_back | inv_left | inv_right);
10319 shield=false;
10320
10321 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10322 o_tile=s_tile;
10323 }
10324
10325
10326 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10327 {
10328 clk4=0;
10329 hyofs = -32768; //No hitbox initially.
10330 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
10331
10332 // Spawn type
10333 if(flags & guy_fadeflicker)
10334 {
10335 clk=0;
10336 superman = 1;
10337 fading=fade_flicker;
10338 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10339 dir=down;
10340
10341 if(!canmove(down,(zfix)8,spw_none,false))
10342 clk3=int32_t(13.0/step);
10343 }
10344 else if(flags & guy_fadeinstant)
10345 {
10346 clk=0;
10347 }
10348 SIZEflags = d->SIZEflags;
10349 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10350 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10351 // al_trace("Enemy txsz:%i\n", txsz);
10352 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10353 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10354 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10355 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10356 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10357 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10358 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10359 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10360 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10361 {
10362 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10363 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10364 }
10365
10366 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10367 }
10368
10369 bool eFriendly::animate(int32_t index)
10370 {
10371 if(switch_hooked) return enemy::animate(index);
10372 if(fallclk||drownclk) return enemy::animate(index);
10373 if(fading)
10374 {
10375 if(++clk4 > 60)
10376 {
10377 clk4=0;
10378 superman=0;
10379 fading=0;
10380
10381 if(flags2&cmbflag_armos && z==0 && fakez==0)
10382 removearmos(x,y,ffcactivated);
10383
10384 clk2=0;
10385
10386 if(!canmove(down,(zfix)8,spw_none,false))
10387 {
10388 dir=0;
10389 y = y.getInt() & 0xF0;
10390 }
10391
10392 return Dead(index);
10393 }
10394 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
10395 removearmos(x,y,ffcactivated);
10396 }
10397
10398 return enemy::animate(index);
10399 }
10400
10401 void eFriendly::draw(BITMAP *dest)
10402 {
10403 update_enemy_frame();
10404 enemy::draw(dest);
10405 }
10406
10407 int32_t eFriendly::takehit(weapon *w)
10408 {
10409 int32_t wpnId = w->id;
10410 int32_t wpnDir = w->dir;
10411
10412 if(wpnId==wHammer && shield && (flags & guy_bkshield)
10413 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
10414 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
10415 {
10416 shield = false;
10417 flags &= ~(inv_left|inv_right|inv_back|inv_front);
10418
10419 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10420 o_tile=s_tile;
10421 }
10422
10423 int32_t ret = enemy::takehit(w);
10424 return ret;
10425 }
10426
10427 void eFriendly::break_shield()
10428 {
10429 if(!shield)
10430 return;
10431
10432 flags&=~(inv_front | inv_back | inv_left | inv_right);
10433 shield=false;
10434
10435 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10436 o_tile=s_tile;
10437 }
10438
10439
10440 153635 void enemy::removearmos(int32_t ax,int32_t ay, word ffcactive)
10441 {
10442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153635 times.
153635 if (ffcactive)
10443 {
10444 removearmosffc(ffcactive-1);
10445 return;
10446 }
10447
2/2
✓ Branch 0 taken 153284 times.
✓ Branch 1 taken 351 times.
153635 if(did_armos)
10448 {
10449 153284 return;
10450 }
10451
10452 351 did_armos=true;
10453 351 ax&=0xF0;
10454 351 ay&=0xF0;
10455 351 int32_t cd = (ax>>4)+ay;
10456 351 int32_t f = MAPFLAG(ax,ay);
10457 351 int32_t f2 = MAPCOMBOFLAG(ax,ay);
10458
10459
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 55 times.
351 if(combobuf[tmpscr->data[cd]].type!=cARMOS)
10460 {
10461 296 return;
10462 }
10463
10464 55 tmpscr->data[cd] = tmpscr->undercombo;
10465 55 tmpscr->cset[cd] = tmpscr->undercset;
10466 55 tmpscr->sflag[cd] = 0;
10467
10468
3/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39 times.
55 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
10469 {
10470 16 tmpscr->data[cd] = tmpscr->secretcombo[sSTAIRS];
10471 16 tmpscr->cset[cd] = tmpscr->secretcset[sSTAIRS];
10472 16 tmpscr->sflag[cd]=tmpscr->secretflag[sSTAIRS];
10473 16 sfx(tmpscr->secretsfx);
10474 16 }
10475
10476
3/4
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 54 times.
55 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
10477 {
10478
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
10479 {
10480 1 additem(ax,ay,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
10481 1 sfx(tmpscr->secretsfx);
10482 1 }
10483 1 }
10484
10485 55 putcombo(scrollbuf,ax,ay,tmpscr->data[cd],tmpscr->cset[cd]);
10486 153635 }
10487
10488 void enemy::removearmosffc(int32_t pos)
10489 {
10490 if(did_armos)
10491 {
10492 return;
10493 }
10494
10495 did_armos=true;
10496 ffcdata& ffc = tmpscr->ffcs[pos];
10497 newcombo const& cmb = combobuf[ffc.getData()];
10498 int32_t f2 = cmb.flag;
10499
10500 if(cmb.type!=cARMOS)
10501 {
10502 return;
10503 }
10504
10505 ffc.setData(tmpscr->undercombo);
10506 ffc.cset = tmpscr->undercset;
10507
10508 if(f2 == mfARMOS_SECRET)
10509 {
10510 ffc.setData(tmpscr->secretcombo[sSTAIRS]);
10511 ffc.cset = tmpscr->secretcset[sSTAIRS];
10512 sfx(tmpscr->secretsfx);
10513 }
10514
10515 if(f2 == mfARMOS_ITEM)
10516 {
10517 if(!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
10518 {
10519 additem(ffc.x,ffc.y,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
10520 sfx(tmpscr->secretsfx);
10521 }
10522 }
10523
10524 putcombo(scrollbuf,ffc.x,ffc.y,ffc.getData(),ffc.cset);
10525 }
10526
10527
10528 106 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10529 106 {
10530 53 fading=fade_flicker;
10531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10532 53 dir=12;
10533 53 movestatus=1;
10534
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 step=0;
10535 53 clk=0;
10536 53 clk4=0;
10537 53 SIZEflags = d->SIZEflags;
10538
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10539 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10540 // al_trace("Enemy txsz:%i\n", txsz);
10541
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10542
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10543
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10544
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10545
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10546
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10547 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10548
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10550 {
10551 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10552 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10553 }
10554
10555
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10556 53 }
10557
10558 17437 bool eGhini::animate(int32_t index)
10559 {
10560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17437 times.
17437 if(switch_hooked) return enemy::animate(index);
10561
2/4
✓ Branch 0 taken 17437 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17437 times.
17437 if(fallclk||drownclk) return enemy::animate(index);
10562
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 17401 times.
17437 if(dying)
10563 36 return Dead(index);
10564
10565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17401 times.
17401 if(dmisc1)
10566 {
10567
2/2
✓ Branch 0 taken 14172 times.
✓ Branch 1 taken 3229 times.
17401 if(misc)
10568 {
10569
2/2
✓ Branch 0 taken 4520 times.
✓ Branch 1 taken 9652 times.
14172 if(clk4>160)
10570 9652 misc=2;
10571
10572
2/2
✓ Branch 0 taken 4520 times.
✓ Branch 1 taken 9652 times.
14172 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
10573 14172 removearmos(x,y,ffcactivated);
10574 14172 }
10575
2/2
✓ Branch 0 taken 3177 times.
✓ Branch 1 taken 52 times.
3229 else if(clk4>=60)
10576 {
10577 52 misc=1;
10578 52 clk3=32;
10579 52 fading=0;
10580
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 if (ffcactivated > 0)
10581 {
10582 guygridffc[ffcactivated-1] = 0;
10583 removearmosffc(ffcactivated-1);
10584 }
10585 else
10586 {
10587 52 guygrid[(int32_t(y)&0xF0)+(int32_t(x)>>4)]=0;
10588 52 removearmos(x,y);
10589 }
10590 52 }
10591 17401 }
10592
10593 17401 clk4++;
10594
10595 17401 return enemy::animate(index);
10596 17437 }
10597
10598 34882 void eGhini::draw(BITMAP *dest)
10599 {
10600 34882 update_enemy_frame();
10601 34882 enemy::draw(dest);
10602 34882 }
10603
10604 2 void eGhini::kickbucket()
10605 {
10606 2 hp=-1000; // don't call death_sfx()
10607 2 }
10608
10609
3/6
✓ Branch 0 taken 1053 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1053 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1053 times.
✗ Branch 5 not taken.
3159 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10610 2106 {
10611
1/2
✓ Branch 0 taken 1053 times.
✗ Branch 1 not taken.
1053 old_y=y;
10612 1053 dir=down;
10613 1053 misc=1;
10614 1053 clk=-15;
10615
10616
2/2
✓ Branch 0 taken 1033 times.
✓ Branch 1 taken 20 times.
1053 if(!BSZ)
10617
1/2
✓ Branch 0 taken 1033 times.
✗ Branch 1 not taken.
1033 clk*=zc_oldrand()%3+1;
10618
10619 // avoid divide by 0 errors
10620
1/2
✓ Branch 0 taken 1053 times.
✗ Branch 1 not taken.
1053 if(dmisc1 == 0)
10621 dmisc1 = 24;
10622
10623
1/2
✓ Branch 0 taken 1053 times.
✗ Branch 1 not taken.
1053 if(dmisc2 == 0)
10624 dmisc2 = 3;
10625
10626 //nets+760;
10627 1053 SIZEflags = d->SIZEflags;
10628
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1053 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1053 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10629 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10630 // al_trace("Enemy txsz:%i\n", txsz);
10631
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1053 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1053 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10632
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1053 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1053 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10633
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1053 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1053 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10634
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1053 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1053 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10635
1/2
✓ Branch 0 taken 1053 times.
✗ Branch 1 not taken.
1053 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10636
1/2
✓ Branch 0 taken 1053 times.
✗ Branch 1 not taken.
1053 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10637 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10638
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1053 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1053 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1053 times.
1053 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10640 {
10641 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10642 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10643 }
10644
10645
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1053 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1053 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10646 1053 }
10647
10648 376383 bool eTektite::animate(int32_t index)
10649 {
10650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 376383 times.
376383 if(switch_hooked) return enemy::animate(index);
10651
4/4
✓ Branch 0 taken 373239 times.
✓ Branch 1 taken 3144 times.
✓ Branch 2 taken 3144 times.
✓ Branch 3 taken 376383 times.
376383 if(fallclk||drownclk) return enemy::animate(index);
10652
2/2
✓ Branch 0 taken 8796 times.
✓ Branch 1 taken 367587 times.
376383 if(dying)
10653 8796 return Dead(index);
10654
10655
2/2
✓ Branch 0 taken 358300 times.
✓ Branch 1 taken 9287 times.
367587 if(clk==0)
10656 {
10657 9287 removearmos(x,y,ffcactivated);
10658 9287 }
10659
10660
2/2
✓ Branch 0 taken 82184 times.
✓ Branch 1 taken 285403 times.
367587 if(get_bit(quest_rules,qr_ENEMIESZAXIS))
10661 {
10662 285403 y=floor_y;
10663 285403 }
10664
10665
9/10
✓ Branch 0 taken 333563 times.
✓ Branch 1 taken 34024 times.
✓ Branch 2 taken 329970 times.
✓ Branch 3 taken 3593 times.
✓ Branch 4 taken 329970 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5905 times.
✓ Branch 7 taken 324065 times.
✓ Branch 8 taken 2463 times.
✓ Branch 9 taken 3442 times.
367587 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
10666 {
10667
4/4
✓ Branch 0 taken 3144 times.
✓ Branch 1 taken 117114 times.
✓ Branch 2 taken 90653 times.
✓ Branch 3 taken 116596 times.
327507 switch(misc)
10668 {
10669 case 0: // normal
10670
2/2
✓ Branch 0 taken 114175 times.
✓ Branch 1 taken 2939 times.
117114 if(!(zc_oldrand()%dmisc1))
10671 {
10672 2939 misc=1;
10673 2939 clk2=32;
10674 2939 }
10675
10676 117114 break;
10677
10678 case 1: // waiting to pounce
10679
2/2
✓ Branch 0 taken 85929 times.
✓ Branch 1 taken 4724 times.
90653 if(--clk2<=0)
10680 {
10681 4724 int32_t r=zc_oldrand();
10682 4724 misc=2;
10683 4724 step=0-(zslongToFix(dstep*100)); // initial speed
10684 4724 clk3=(r&1)+2; // left or right
10685 4724 clk2start=clk2=(r&31)+10; // flight time
10686
10687
2/2
✓ Branch 0 taken 4085 times.
✓ Branch 1 taken 639 times.
4724 if(y<32) clk2+=2; // make them come down from top of screen
10688
10689
2/2
✓ Branch 0 taken 3562 times.
✓ Branch 1 taken 1162 times.
4724 if(y>112) clk2-=2; // make them go back up
10690
10691 4724 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
10692 4724 }
10693
10694 90653 break;
10695
10696 case 2: // in flight
10697 116596 move(step);
10698
10699
2/2
✓ Branch 0 taken 56987 times.
✓ Branch 1 taken 59609 times.
116596 if(step>0) //going down
10700 {
10701
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 56831 times.
56987 if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE)
10702 {
10703 156 step=0-step;
10704 156 }
10705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56831 times.
56831 else if(COMBOTYPE(x+8,y+16)==cNOENEMY)
10706 {
10707 step=0-step;
10708 }
10709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56831 times.
56831 else if(ispitfall(x+8,y+16))
10710 {
10711 step=0-step;
10712 }
10713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56831 times.
56831 else if(MAPFLAG(x+8,y+16)==mfNOENEMY)
10714 {
10715 step=0-step;
10716 }
10717
1/2
✓ Branch 0 taken 56831 times.
✗ Branch 1 not taken.
56831 else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY)
10718 {
10719 step=0-step;
10720 }
10721 56987 }
10722
2/2
✓ Branch 0 taken 3819 times.
✓ Branch 1 taken 55790 times.
59609 else if(step<0)
10723 {
10724
2/2
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 55571 times.
55790 if(COMBOTYPE(x+8,y)==cNOJUMPZONE)
10725 {
10726 219 step=0-step;
10727 219 }
10728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55571 times.
55571 else if(COMBOTYPE(x+8,y)==cNOENEMY)
10729 {
10730 step=0-step;
10731 }
10732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55571 times.
55571 else if(ispitfall(x+8,y))
10733 {
10734 step=0-step;
10735 }
10736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55571 times.
55571 else if(MAPFLAG(x+8,y)==mfNOENEMY)
10737 {
10738 step=0-step;
10739 }
10740
1/2
✓ Branch 0 taken 55571 times.
✗ Branch 1 not taken.
55571 else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY)
10741 {
10742 step=0-step;
10743 }
10744 55790 }
10745
10746
2/2
✓ Branch 0 taken 57792 times.
✓ Branch 1 taken 58804 times.
116596 if(clk3==left)
10747 {
10748
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 57691 times.
57792 if(COMBOTYPE(x,y+8)==cNOJUMPZONE)
10749 {
10750 101 clk3^=1;
10751 101 }
10752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57691 times.
57691 else if(COMBOTYPE(x,y+8)==cNOENEMY)
10753 {
10754 clk3^=1;
10755 }
10756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57691 times.
57691 else if(ispitfall(x,y+8))
10757 {
10758 clk3^=1;
10759 }
10760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57691 times.
57691 else if(MAPFLAG(x,y+8)==mfNOENEMY)
10761 {
10762 clk3^=1;
10763 }
10764
1/2
✓ Branch 0 taken 57691 times.
✗ Branch 1 not taken.
57691 else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY)
10765 {
10766 clk3^=1;
10767 }
10768 57792 }
10769 else
10770 {
10771
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 58713 times.
58804 if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE)
10772 {
10773 91 clk3^=1;
10774 91 }
10775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58713 times.
58713 else if(COMBOTYPE(x+16,y+8)==cNOENEMY)
10776 {
10777 clk3^=1;
10778 }
10779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58713 times.
58713 else if(ispitfall(x+16,y+8))
10780 {
10781 clk3^=1;
10782 }
10783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58713 times.
58713 else if(MAPFLAG(x+16,y+8)==mfNOENEMY)
10784 {
10785 clk3^=1;
10786 }
10787
1/2
✓ Branch 0 taken 58713 times.
✗ Branch 1 not taken.
58713 else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY)
10788 {
10789 clk3^=1;
10790 }
10791 }
10792
10793 116596 --c;
10794
10795
4/4
✓ Branch 0 taken 34791 times.
✓ Branch 1 taken 81805 times.
✓ Branch 2 taken 77301 times.
✓ Branch 3 taken 39295 times.
116596 if(c<0 && step<zslongToFix(dstep*100))
10796 {
10797 39295 step+=zslongToFix(dmisc3*100);
10798 39295 }
10799
10800 116596 int32_t nb=get_bit(quest_rules,qr_NOBORDER) ? 16 : 0;
10801
10802
2/2
✓ Branch 0 taken 116482 times.
✓ Branch 1 taken 114 times.
116596 if(x<=16-nb) clk3=right;
10803
10804
2/2
✓ Branch 0 taken 116388 times.
✓ Branch 1 taken 208 times.
116596 if(x>=224+nb) clk3=left;
10805
10806 116596 x += (clk3==left) ? -1 : 1;
10807
10808
4/4
✓ Branch 0 taken 6117 times.
✓ Branch 1 taken 110479 times.
✓ Branch 2 taken 1572 times.
✓ Branch 3 taken 108907 times.
116596 if((--clk2<=0 && y>=16-nb) || y>=144+nb)
10809 {
10810
4/4
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 4318 times.
✓ Branch 2 taken 83 times.
✓ Branch 3 taken 144 times.
7689 if(y>=144+nb && get_bit(quest_rules,qr_ENEMIESZAXIS))
10811 {
10812 144 step=0-step;
10813 144 y--;
10814 144 }
10815
2/2
✓ Branch 0 taken 3320 times.
✓ Branch 1 taken 1081 times.
4401 else if(zc_oldrand()%dmisc2) //land and wait
10816 {
10817 3320 clk=misc=0;
10818 3320 } //land and jump again
10819 else
10820 {
10821 1081 misc=1;
10822 1081 clk2=0;
10823 }
10824 4545 }
10825
10826 113452 break;
10827 } // switch
10828 324363 }
10829
10830
4/4
✓ Branch 0 taken 285403 times.
✓ Branch 1 taken 79040 times.
✓ Branch 2 taken 190784 times.
✓ Branch 3 taken 94619 times.
364443 if(get_bit(quest_rules,qr_ENEMIESZAXIS) && misc==2)
10831 {
10832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94619 times.
94619 if (moveflags & FLAG_USE_FAKE_Z)
10833 {
10834 int32_t tempy = floor_y;
10835 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
10836 floor_y = y;
10837 y=tempy-fakez;
10838 old_y = y;
10839 }
10840 else
10841 {
10842 94619 int32_t tempy = floor_y;
10843
6/6
✓ Branch 0 taken 47176 times.
✓ Branch 1 taken 47443 times.
✓ Branch 2 taken 2107 times.
✓ Branch 3 taken 92512 times.
✓ Branch 4 taken 46124 times.
✓ Branch 5 taken 46388 times.
94619 z=zc_max(0,zc_min(clk2start-clk2,clk2));
10844 94619 floor_y = y;
10845 94619 y=tempy-z;
10846 94619 old_y = y;
10847 }
10848 94619 }
10849
10850
4/4
✓ Branch 0 taken 3593 times.
✓ Branch 1 taken 360850 times.
✓ Branch 2 taken 662 times.
✓ Branch 3 taken 2931 times.
364443 if(stunclk && (clk&31)==1)
10851 2931 clk=0;
10852
10853 364443 return enemy::animate(index);
10854 373239 }
10855
10856 156996 void eTektite::drawshadow(BITMAP *dest,bool translucent)
10857 {
10858
5/6
✓ Branch 0 taken 29120 times.
✓ Branch 1 taken 127876 times.
✓ Branch 2 taken 29120 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11386 times.
✓ Branch 5 taken 17734 times.
156996 if(z<1 && fakez<1 && get_bit(quest_rules,qr_ENEMIESZAXIS))
10859 17734 return;
10860
10861 139262 int32_t tempy=yofs;
10862 139262 int32_t fdiv = frate/4;
10863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139262 times.
139262 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
10864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139262 times.
139262 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
10865 139262 efrate:((clk>=(frate>>1))?1:0);
10866 139262 flip = 0;
10867 139262 shadowtile = wpnsbuf[spr_shadow].tile;
10868
10869
1/2
✓ Branch 0 taken 139262 times.
✗ Branch 1 not taken.
139262 if(get_bit(quest_rules,qr_NEWENEMYTILES))
10870 {
10871
2/2
✓ Branch 0 taken 47584 times.
✓ Branch 1 taken 91678 times.
139262 if(misc==0)
10872 {
10873 47584 shadowtile+=f2;
10874 47584 }
10875
2/2
✓ Branch 0 taken 40881 times.
✓ Branch 1 taken 50797 times.
91678 else if(misc!=1)
10876 50797 shadowtile+=2;
10877 139262 }
10878 else
10879 {
10880 if(misc==0)
10881 {
10882 shadowtile += f2 ? 1 : 0;
10883 }
10884 else if(misc!=1)
10885 {
10886 ++shadowtile;
10887 }
10888 }
10889
10890 139262 yofs+=8;
10891
10892
4/4
✓ Branch 0 taken 11386 times.
✓ Branch 1 taken 127876 times.
✓ Branch 2 taken 5992 times.
✓ Branch 3 taken 5394 times.
139262 if(!get_bit(quest_rules,qr_ENEMIESZAXIS) && misc==2)
10893 {
10894
6/6
✓ Branch 0 taken 2678 times.
✓ Branch 1 taken 2716 times.
✓ Branch 2 taken 320 times.
✓ Branch 3 taken 5074 times.
✓ Branch 4 taken 2572 times.
✓ Branch 5 taken 2502 times.
5394 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
10895 5394 }
10896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139262 times.
139262 if(!shadow_overpit(this))
10897 139262 enemy::drawshadow(dest,translucent);
10898 139262 yofs=tempy;
10899 156996 }
10900
10901 884972 void eTektite::draw(BITMAP *dest)
10902 {
10903 884972 update_enemy_frame();
10904 884972 enemy::draw(dest);
10905 884972 }
10906
10907 396 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10908 396 {
10909
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 step=zslongToFix(guysbuf[id&0xFFF].step*100);
10910 198 superman=1;
10911 198 dir=8;
10912 198 hxofs=1000;
10913 198 mainguy=false;
10914 198 count_enemy=false;
10915
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10916 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10917 // al_trace("Enemy txsz:%i\n", txsz);
10918
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
10919
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = hxsz;
10920
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = hysz;
10921
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
10922
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
10923
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
10924 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10925
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
10926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
198 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10927 {
10928 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
10929 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10930 }
10931
10932
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
10933 198 }
10934
10935 117987 bool eItemFairy::animate(int32_t index)
10936 {
10937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117987 times.
117987 if(switch_hooked) return enemy::animate(index);
10938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117987 times.
117987 if(dying)
10939 return Dead(index);
10940
10941 //if(clk>32)
10942 117987 misc=1;
10943 117987 bool w=watch;
10944 117987 watch=false;
10945 117987 variable_walk_8(misc?3:0,0,8,spw_floater);
10946 117987 watch=w;
10947
10948
2/2
✓ Branch 0 taken 567 times.
✓ Branch 1 taken 117420 times.
117987 if(clk==0)
10949 {
10950 567 removearmos(x,y,ffcactivated);
10951 567 }
10952
10953 117987 return enemy::animate(index);
10954 117987 }
10955
10956 236280 void eItemFairy::draw(BITMAP *dest)
10957 {
10958 //these are here to bypass compiler warnings about unused arguments
10959 236280 dest=dest;
10960 236280 }
10961
10962 738 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10963 738 {
10964 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
10965
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 369 times.
✓ Branch 2 taken 369 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 369 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 369 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 369 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 369 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 369 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 369 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 369 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 369 times.
✗ Branch 19 not taken.
369 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
10966 369 dir=8;
10967 369 movestatus=1;
10968 369 clk=0;
10969
1/2
✓ Branch 0 taken 369 times.
✗ Branch 1 not taken.
369 step=0;
10970 //nets+720;
10971 369 SIZEflags = d->SIZEflags;
10972
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 369 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
369 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10973 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10974 // al_trace("Enemy txsz:%i\n", txsz);
10975
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 369 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
369 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10976
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 369 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
369 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10977
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 369 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
369 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10978
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 369 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
369 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10979
1/2
✓ Branch 0 taken 369 times.
✗ Branch 1 not taken.
369 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10980
1/2
✓ Branch 0 taken 369 times.
✗ Branch 1 not taken.
369 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10981 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10982
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 369 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
369 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 369 times.
369 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10984 {
10985 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10986 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10987 }
10988
10989
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 369 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
369 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10990 369 }
10991
10992 120469 bool ePeahat::animate(int32_t index)
10993 {
10994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120469 times.
120469 if(switch_hooked) return enemy::animate(index);
10995
2/4
✓ Branch 0 taken 120469 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 120469 times.
120469 if(fallclk||drownclk) return enemy::animate(index);
10996
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 120407 times.
120469 if(slide())
10997 {
10998 62 return false;
10999 }
11000
11001
2/2
✓ Branch 0 taken 306 times.
✓ Branch 1 taken 120101 times.
120407 if(dying)
11002 306 return Dead(index);
11003
11004
2/2
✓ Branch 0 taken 119323 times.
✓ Branch 1 taken 778 times.
120101 if(clk==0)
11005 {
11006 778 removearmos(x,y,ffcactivated);
11007 778 }
11008
11009
4/4
✓ Branch 0 taken 117324 times.
✓ Branch 1 taken 2777 times.
✓ Branch 2 taken 56121 times.
✓ Branch 3 taken 61203 times.
120101 if(stunclk==0 && clk>96)
11010 61203 misc=1;
11011
11012
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 118467 times.
120101 if(!watch)
11013
2/2
✓ Branch 0 taken 81394 times.
✓ Branch 1 taken 37073 times.
118467 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16);
11014
11015
3/4
✓ Branch 0 taken 24100 times.
✓ Branch 1 taken 96001 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24100 times.
120101 if(get_bit(quest_rules,qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11016 {
11017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24100 times.
24100 if (moveflags & FLAG_USE_FAKE_Z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
11018 24100 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
11019 24100 }
11020
11021
3/4
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 118467 times.
✓ Branch 2 taken 1634 times.
✗ Branch 3 not taken.
120101 if(watch && get_bit(quest_rules,qr_PEAHATCLOCKVULN))
11022 1634 superman=0;
11023 else
11024
2/2
✓ Branch 0 taken 113390 times.
✓ Branch 1 taken 5077 times.
118467 superman=(movestatus && !get_bit(quest_rules,qr_ENEMIESZAXIS)) ? 1 : 0;
11025 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
11026
1/2
✓ Branch 0 taken 120101 times.
✗ Branch 1 not taken.
120101 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
11027 {
11028
2/2
✓ Branch 0 taken 2777 times.
✓ Branch 1 taken 117324 times.
120101 if ( stunclk ) --stunclk;
11029 120101 }
11030 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
11031 //Pretty sure this was always an error. -Z ( 14FEB2019 )
11032
11033
11034
2/2
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 119890 times.
120101 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
11035
11036 120101 return enemy::animate(index);
11037 120469 }
11038
11039 12052 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
11040 {
11041 12052 int32_t tempy=yofs;
11042 12052 flip = 0;
11043 12052 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
11044
11045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12052 times.
12052 if(!get_bit(quest_rules,qr_ENEMIESZAXIS))
11046 {
11047 yofs+=8;
11048 yofs+=int32_t(step/zslongToFix(dstep*10));
11049 }
11050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12052 times.
12052 if(!shadow_overpit(this))
11051 12052 enemy::drawshadow(dest,translucent);
11052 12052 yofs=tempy;
11053 12052 }
11054
11055 263743 void ePeahat::draw(BITMAP *dest)
11056 {
11057 263743 update_enemy_frame();
11058 263743 enemy::draw(dest);
11059 263743 }
11060
11061 646 int32_t ePeahat::takehit(weapon *w)
11062 {
11063 646 int32_t wpnId = w->id;
11064 646 int32_t enemyHitWeapon = w->parentitem;
11065
11066
3/6
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 646 times.
646 if(dying || clk<0 || hclk>0)
11067 return 0;
11068
11069
4/4
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 172 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 102 times.
776 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
11070 // fire boomerang, for nailing peahats
11071
4/6
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 344 times.
✓ Branch 3 taken 130 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 130 times.
474 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
11072 446 return 0;
11073
11074 // Time for a kludge...
11075 200 int32_t s = superman;
11076 200 superman = 0;
11077 200 int32_t ret = enemy::takehit(w);
11078 200 superman = s;
11079
11080 // Anyway...
11081
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 138 times.
200 if(stunclk == 160)
11082 {
11083 138 clk2=0;
11084 138 movestatus=0;
11085 138 misc=0;
11086 138 clk=0;
11087 138 step=0;
11088 138 }
11089
11090 200 return ret;
11091 646 }
11092
11093 // auomatically kill off enemy (for rooms with ringleaders)
11094 void ePeahat::kickbucket()
11095 {
11096 hp=-1000; // don't call death_sfx()
11097 }
11098
11099 1276 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11100 1276 {
11101 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
11102
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 355 times.
638 if(dmisc1==0)
11103 {
11104 355 misc=-1; //Line of Sight leevers
11105 355 clk-=16;
11106 355 }
11107 638 clk3 = 0;
11108 //nets+1460;
11109
1/2
✓ Branch 0 taken 638 times.
✗ Branch 1 not taken.
638 temprule=(get_bit(quest_rules,qr_NEWENEMYTILES)) != 0;
11110 638 submerged = false;
11111 638 SIZEflags = d->SIZEflags;
11112
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 638 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
638 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11113 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
11114 // al_trace("Enemy txsz:%i\n", txsz);
11115
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 638 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
638 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
11116
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 638 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
638 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
11117
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 638 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
638 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
11118
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 638 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
638 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
11119
1/2
✓ Branch 0 taken 638 times.
✗ Branch 1 not taken.
638 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
11120
1/2
✓ Branch 0 taken 638 times.
✗ Branch 1 not taken.
638 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
11121 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
11122
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 638 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
638 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
11123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 638 times.
638 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
11124 {
11125 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11126 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
11127 }
11128
11129
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 638 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
638 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
11130 638 }
11131
11132 bool eLeever::isSubmerged() const
11133 {
11134 Z_scripterrlog("misc is: %d\n", misc);
11135 return misc <= 0;
11136
11137 }
11138
11139 181304 bool eLeever::animate(int32_t index)
11140 {
11141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 181304 times.
181304 if(switch_hooked) return enemy::animate(index);
11142
2/4
✓ Branch 0 taken 181304 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 181304 times.
181304 if(fallclk||drownclk)
11143 {
11144 return enemy::animate(index);
11145 }
11146
2/2
✓ Branch 0 taken 7884 times.
✓ Branch 1 taken 173420 times.
181304 if(dying)
11147 7884 return Dead(index);
11148
11149
2/2
✓ Branch 0 taken 163284 times.
✓ Branch 1 taken 10136 times.
173420 if(clk==0)
11150 {
11151 10136 removearmos(x,y,ffcactivated);
11152 10136 }
11153
11154
4/4
✓ Branch 0 taken 148210 times.
✓ Branch 1 taken 25210 times.
✓ Branch 2 taken 1327 times.
✓ Branch 3 taken 146883 times.
173420 if(clk>=0 && !slide())
11155 {
11156 // switch(d->misc1)
11157
2/2
✓ Branch 0 taken 53783 times.
✓ Branch 1 taken 93100 times.
146883 switch(dmisc1)
11158 {
11159 case 0: //line of sight
11160 case 2:
11161
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 16867 times.
✓ Branch 2 taken 6006 times.
✓ Branch 3 taken 7236 times.
✓ Branch 4 taken 3201 times.
✓ Branch 5 taken 18240 times.
✓ Branch 6 taken 859 times.
✓ Branch 7 taken 1374 times.
53783 switch(misc) //is this leever active
11162 {
11163 case -1: //submerged
11164 {
11165
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 16867 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16867 if (!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
11166
4/4
✓ Branch 0 taken 7609 times.
✓ Branch 1 taken 9258 times.
✓ Branch 2 taken 7582 times.
✓ Branch 3 taken 27 times.
16867 if((dmisc1==2)&&(zc_oldrand()&255))
11167 {
11168 7582 break;
11169 }
11170
11171 9285 int32_t active=0;
11172
11173
2/2
✓ Branch 0 taken 52381 times.
✓ Branch 1 taken 9285 times.
61666 for(int32_t i=0; i<guys.Count(); i++)
11174 {
11175
4/4
✓ Branch 0 taken 42323 times.
✓ Branch 1 taken 10058 times.
✓ Branch 2 taken 24280 times.
✓ Branch 3 taken 18043 times.
52381 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
11176 {
11177 18043 ++active;
11178 18043 }
11179 52381 }
11180
11181
2/2
✓ Branch 0 taken 8920 times.
✓ Branch 1 taken 365 times.
9285 if(active<((dmisc1==2)?1:2))
11182 {
11183 365 misc=0; //activate this one
11184 365 clk3=1; //This needs to be set so that it knows that it's being emerged of it's own will and not because it got stunned.
11185 365 }
11186 }
11187 9285 break;
11188
11189 case 0:
11190 {
11191
11192
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6006 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6006 if (!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
11193 {
11194 misc=1;
11195 clk2=0;
11196 }
11197
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 5972 times.
6006 else if (clk3<=0)
11198 {
11199 34 misc = -1;
11200 34 break;
11201 }
11202 5972 int32_t s=0;
11203
11204
2/2
✓ Branch 0 taken 41181 times.
✓ Branch 1 taken 5972 times.
47153 for(int32_t i=0; i<guys.Count(); i++)
11205 {
11206
4/4
✓ Branch 0 taken 14835 times.
✓ Branch 1 taken 26346 times.
✓ Branch 2 taken 13756 times.
✓ Branch 3 taken 1079 times.
41181 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
11207 {
11208 1079 ++s;
11209 1079 }
11210 41181 }
11211
11212
2/2
✓ Branch 0 taken 1079 times.
✓ Branch 1 taken 4893 times.
5972 if(s>0)
11213 {
11214 1079 break;
11215 }
11216
11217 4893 int32_t d2=zc_oldrand()&1;
11218
11219
2/2
✓ Branch 0 taken 1135 times.
✓ Branch 1 taken 3758 times.
4893 if(HeroDir()>=left)
11220 {
11221 3758 d2+=2;
11222 3758 }
11223
11224
4/4
✓ Branch 0 taken 4601 times.
✓ Branch 1 taken 292 times.
✓ Branch 2 taken 135 times.
✓ Branch 3 taken 4466 times.
4893 if(canplace(d2) || canplace(d2^1))
11225 {
11226 427 misc=1;
11227 427 clk2=0;
11228 427 clk=0;
11229 427 }
11230 }
11231 4893 break;
11232
11233 case 1:
11234
11235
3/8
✓ Branch 0 taken 6812 times.
✓ Branch 1 taken 424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6812 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
7236 if(++clk2>16||(!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
11236
11237 7236 break;
11238
11239 case 2:
11240
11241
3/8
✓ Branch 0 taken 2812 times.
✓ Branch 1 taken 389 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2812 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3201 if(++clk2>24||(!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
11242
11243 3201 break;
11244
11245 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
11246 case 3:
11247
11248
5/6
✓ Branch 0 taken 16247 times.
✓ Branch 1 taken 1993 times.
✓ Branch 2 taken 16247 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 524 times.
✓ Branch 5 taken 15723 times.
18240 if(stunclk || frozenclock || watch) break;
11249
11250
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 15688 times.
15723 if(scored) dir^=1;
11251
11252
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 15626 times.
15723 if(!canmove(dir,false)) misc=4;
11253 15626 else move(zslongToFix(dstep*100));
11254
11255 15723 break;
11256
11257 case 4:
11258
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 859 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
859 if (!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
11259
2/2
✓ Branch 0 taken 766 times.
✓ Branch 1 taken 93 times.
859 if(--clk2<=16)
11260 {
11261 93 misc=5;
11262 93 clk=8;
11263 93 }
11264
11265 859 break;
11266
11267 case 5:
11268
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1374 if (!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
11269
2/2
✓ Branch 0 taken 1289 times.
✓ Branch 1 taken 85 times.
1374 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
11270
11271 1374 break;
11272 } // switch(misc)
11273
11274 53783 break;
11275
11276 default: //random
11277 // step=d->misc3/100.0;
11278
11279 93100 step=zslongToFix(dmisc3*100);
11280
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 93100 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
93100 if (get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
11281 else if (!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
11282 {
11283 if (clk2 < 48) clk2+=2;
11284 if (clk2 >= 300) clk2-=2;
11285 }
11286
11287
2/2
✓ Branch 0 taken 10595 times.
✓ Branch 1 taken 82505 times.
93100 if(clk2<32) misc=1;
11288
2/2
✓ Branch 0 taken 5255 times.
✓ Branch 1 taken 77250 times.
82505 else if(clk2<48) misc=2;
11289
2/2
✓ Branch 0 taken 52584 times.
✓ Branch 1 taken 24666 times.
77250 else if(clk2<300)
11290 {
11291 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
11292 {
11293 fix_coords();
11294 }*/
11295 52584 misc=3;
11296 52584 step = zslongToFix(dstep*100);
11297 52584 }
11298
2/2
✓ Branch 0 taken 1992 times.
✓ Branch 1 taken 22674 times.
24666 else if(clk2<316) misc=2;
11299
2/2
✓ Branch 0 taken 10698 times.
✓ Branch 1 taken 11976 times.
22674 else if(clk2<412) misc=1;
11300
2/2
✓ Branch 0 taken 11888 times.
✓ Branch 1 taken 88 times.
11976 else if(clk2<540)
11301 {
11302 11888 misc=0;
11303 11888 step=0;
11304 11888 }
11305 88 else clk2=0;
11306
11307
2/2
✓ Branch 0 taken 92778 times.
✓ Branch 1 taken 322 times.
93100 if(clk2==48) clk=0;
11308
11309 // variable_walk(d->rate, d->homing, 0);
11310 93100 variable_walk(rate, homing, 0);
11311 93100 } // switch(dmisc1)
11312 146883 }
11313
11314 173420 hxofs=(misc>=2)?0:1000;
11315 173420 return enemy::animate(index);
11316 181304 }
11317
11318 9494 bool eLeever::canplace(int32_t d2)
11319 {
11320 9494 int32_t nx=HeroX();
11321 9494 int32_t ny=HeroY();
11322
11323
2/2
✓ Branch 0 taken 2180 times.
✓ Branch 1 taken 7314 times.
9494 if(d2<left) ny&=0xF0;
11324 7314 else nx&=0xF0;
11325
11326
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1075 times.
✓ Branch 2 taken 1105 times.
✓ Branch 3 taken 3644 times.
✓ Branch 4 taken 3670 times.
9494 switch(d2)
11327 {
11328 // case up: ny-=((d->misc1==0)?32:48); break;
11329 // case down: ny+=((d->misc1==0)?32:48); if(ny-HeroY()<32) ny+=((d->misc1==0)?16:0); break;
11330 // case left: nx-=((d->misc1==0)?32:48); break;
11331 // case right: nx+=((d->misc1==0)?32:48); if(nx-HeroX()<32) nx+=((d->misc1==0)?16:0); break;
11332 case up:
11333
2/2
✓ Branch 0 taken 1047 times.
✓ Branch 1 taken 28 times.
1075 ny-=((dmisc1==0||dmisc1==2)?32:48);
11334 1075 break;
11335
11336 case down:
11337
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 1074 times.
1105 ny+=((dmisc1==0||dmisc1==2)?32:48);
11338
11339
4/4
✓ Branch 0 taken 580 times.
✓ Branch 1 taken 525 times.
✓ Branch 2 taken 571 times.
✓ Branch 3 taken 9 times.
1105 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
11340
11341 1105 break;
11342
11343 case left:
11344
2/2
✓ Branch 0 taken 3044 times.
✓ Branch 1 taken 600 times.
3644 nx-=((dmisc1==0||dmisc1==2)?32:48);
11345 3644 break;
11346
11347 case right:
11348
2/2
✓ Branch 0 taken 595 times.
✓ Branch 1 taken 3075 times.
3670 nx+=((dmisc1==0||dmisc1==2)?32:48);
11349
11350
4/4
✓ Branch 0 taken 3161 times.
✓ Branch 1 taken 509 times.
✓ Branch 2 taken 2606 times.
✓ Branch 3 taken 555 times.
3670 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
11351
11352 3670 break;
11353 }
11354
11355
4/4
✓ Branch 0 taken 4040 times.
✓ Branch 1 taken 5454 times.
✓ Branch 2 taken 1835 times.
✓ Branch 3 taken 2205 times.
9494 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
11356 7289 return false;
11357
11358
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 2048 times.
2205 if(d2>=left)
11359
4/4
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 1844 times.
✓ Branch 2 taken 1778 times.
✓ Branch 3 taken 270 times.
2048 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
11360 1778 return false;
11361
11362 427 x=nx;
11363 427 y=ny;
11364 427 dir=d2^1;
11365 427 return true;
11366 9494 }
11367
11368 181461 void eLeever::draw(BITMAP *dest)
11369 {
11370 // cs=d->cset;
11371 181461 cs=dcset;
11372 181461 update_enemy_frame();
11373
2/4
✓ Branch 0 taken 181461 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 181461 times.
181461 if(!fallclk&&!drownclk)
11374 {
11375
2/2
✓ Branch 0 taken 120938 times.
✓ Branch 1 taken 60523 times.
181461 switch(misc)
11376 {
11377 case -1:
11378 case 0:
11379 60523 return;
11380 }
11381 120938 }
11382
11383 120938 enemy::draw(dest);
11384 181461 }
11385
11386 570 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11387 570 {
11388 //zprint2("eWallM::eWallM\n");
11389 285 hashero=false;
11390 //nets+1000;
11391 285 SIZEflags = d->SIZEflags;
11392
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 285 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
285 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11393 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
11394 // al_trace("Enemy txsz:%i\n", txsz);
11395
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 285 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
285 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
11396
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 285 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
285 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
11397
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 285 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
285 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
11398
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 285 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
285 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
11399
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
285 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
11400
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
285 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
11401 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
11402
1/4
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
285 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
11403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 285 times.
285 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
11404 {
11405 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11406 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
11407 }
11408
11409
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 285 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
285 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
11410 285 }
11411
11412 205955 bool eWallM::animate(int32_t index)
11413 {
11414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205955 times.
205955 if(switch_hooked) return enemy::animate(index);
11415
2/4
✓ Branch 0 taken 205955 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 205955 times.
205955 if(fallclk||drownclk)
11416 {
11417 return enemy::animate(index);
11418 }
11419
2/2
✓ Branch 0 taken 4158 times.
✓ Branch 1 taken 201797 times.
205955 if(dying)
11420 4158 return Dead(index);
11421
11422
2/2
✓ Branch 0 taken 188704 times.
✓ Branch 1 taken 13093 times.
201797 if(clk==0)
11423 {
11424 13093 removearmos(x,y,ffcactivated);
11425 13093 }
11426
11427 201797 hxofs=1000;
11428
2/2
✓ Branch 0 taken 56374 times.
✓ Branch 1 taken 145423 times.
201797 if(misc==0) //inside wall, ready to spawn?
11429 {
11430 //zprint2("Wallmaster is ready to spawn, clk is: %d\n",clk);
11431 //zprint2("frame is: %d\n",frame);
11432 //zprint2("wallm_load_clk is: %d\n",wallm_load_clk);
11433
4/4
✓ Branch 0 taken 96285 times.
✓ Branch 1 taken 49138 times.
✓ Branch 2 taken 4863 times.
✓ Branch 3 taken 91422 times.
145423 if(frame-wallm_load_clk>80 && clk>=0)
11434 {
11435 //zprint2("getting wall\n");
11436 91422 int32_t wall=hero_on_wall();
11437 //zprint2("Wallmaster wall is %d\n",wall);
11438 91422 int32_t wallm_cnt=0;
11439
11440
2/2
✓ Branch 0 taken 649505 times.
✓ Branch 1 taken 91422 times.
740927 for(int32_t i=0; i<guys.Count(); i++)
11441
2/2
✓ Branch 0 taken 287043 times.
✓ Branch 1 taken 362462 times.
1011967 if(((enemy*)guys.spr(i))->family==eeWALLM)
11442 {
11443 362462 int32_t m=((enemy*)guys.spr(i))->misc;
11444
11445
4/4
✓ Branch 0 taken 18871 times.
✓ Branch 1 taken 343591 times.
✓ Branch 2 taken 11313 times.
✓ Branch 3 taken 7558 times.
362462 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
11446 {
11447 7558 ++wallm_cnt;
11448 7558 }
11449 362462 }
11450
11451
2/2
✓ Branch 0 taken 91091 times.
✓ Branch 1 taken 331 times.
91422 if(wall>0)
11452 {
11453 331 --wall;
11454 331 misc=1; //emerging from the wall?
11455 //zprint2("Wallmaster is emerging\n");
11456 331 clk2=0;
11457 331 clk3=wall^1;
11458 331 wallm_load_clk=frame;
11459
11460
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 132 times.
331 if(wall<=down)
11461 {
11462
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 168 times.
199 if(HeroDir()==left)
11463 31 dir=right;
11464 else
11465 168 dir=left;
11466 199 }
11467 else
11468 {
11469
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 98 times.
132 if(HeroDir()==up)
11470 34 dir=down;
11471 else
11472 98 dir=up;
11473 }
11474
11475
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 88 times.
✓ Branch 4 taken 44 times.
331 switch(wall)
11476 {
11477 case up:
11478 111 y=0;
11479 111 break;
11480
11481 case down:
11482 88 y=160;
11483 88 break;
11484
11485 case left:
11486 88 x=0;
11487 88 break;
11488
11489 case right:
11490 44 x=240;
11491 44 break;
11492 }
11493
11494 //zprint2("Wallmaster (p1) x is %d\n",x);
11495 //zprint2("Wallmaster (p1) y is %d\n",y);
11496
11497
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 168 times.
✓ Branch 4 taken 31 times.
331 switch(dir)
11498 {
11499 case up:
11500 98 y=(HeroY()+48-(wallm_cnt&1)*12);
11501 98 flip=wall&1;
11502 98 break;
11503
11504 case down:
11505 34 y=(HeroY()-48+(wallm_cnt&1)*12);
11506 34 flip=((wall&1)^1)+2;
11507 34 break;
11508
11509 case left:
11510 168 x=(HeroX()+48-(wallm_cnt&1)*12);
11511 168 flip=(wall==up?2:0)+1;
11512 168 break;
11513
11514 case right:
11515 31 x=(HeroX()-48+(wallm_cnt&1)*12);
11516 31 flip=(wall==up?2:0);
11517 31 break;
11518 }
11519
11520 //zprint2("Wallmaster (p2) x is %d\n",x);
11521 //zprint2("Wallmaster (p2) y is %d\n",y);
11522 331 }
11523 91422 }
11524 145423 }
11525 else
11526 56374 wallm_crawl();
11527
11528 201797 return enemy::animate(index);
11529 205955 }
11530
11531 56374 void eWallM::wallm_crawl()
11532 {
11533 56374 bool w=watch;
11534 56374 hxofs=0;
11535
11536
2/2
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 55950 times.
56374 if(slide())
11537 {
11538 424 return;
11539 }
11540
11541 // if(dying || watch || (!hashero && stunclk))
11542
6/8
✓ Branch 0 taken 55950 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55661 times.
✓ Branch 3 taken 289 times.
✓ Branch 4 taken 42004 times.
✓ Branch 5 taken 13657 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 42004 times.
55950 if(dying || (!hashero && ( stunclk || frozenclock )))
11543 {
11544 13657 return;
11545 }
11546
11547 42293 watch=false;
11548 42293 ++clk2;
11549 // Misc1: slightly different movement
11550 //zprint2("wallmaster crawl\n");
11551 //zprint2("wallmaster tmpdstep is %d\n",tmpdstep);
11552 42293 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
11553
11554 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
11555 //zprint2("wallmaster crawl tmpmisc is: %d\n", tmpmisc);
11556 //zprint2("wallmaster crawl tmpmisc4 is: %d\n", tmpmisc4);
11557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42293 times.
42293 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
11558 //zprint2("wallmaster crawl misc is: %d\n", misc);
11559
5/6
✓ Branch 0 taken 2791 times.
✓ Branch 1 taken 39502 times.
✓ Branch 2 taken 2140 times.
✓ Branch 3 taken 651 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2140 times.
42293 if(w&&misc>=3&&misc<=5)
11560 {
11561 2140 --clk2;
11562 2140 }
11563
11564
4/4
✓ Branch 0 taken 18245 times.
✓ Branch 1 taken 18781 times.
✓ Branch 2 taken 5178 times.
✓ Branch 3 taken 89 times.
42293 switch(misc)
11565 {
11566 case 1:
11567 case 2:
11568 18781 zc_swap(dir,clk3);
11569 18781 move(step);
11570 18781 zc_swap(dir,clk3);
11571 18781 break;
11572
11573 case 3:
11574 case 4:
11575 case 5:
11576
2/2
✓ Branch 0 taken 2140 times.
✓ Branch 1 taken 16105 times.
18245 if(w)
11577 {
11578 2140 watch=w;
11579 2140 return;
11580 }
11581
11582 16105 move(step);
11583 16105 break;
11584
11585 case 6:
11586 case 7:
11587 5178 zc_swap(dir,clk3);
11588 5178 dir^=1;
11589 5178 move(step);
11590 5178 dir^=1;
11591 5178 zc_swap(dir,clk3);
11592 5178 break;
11593
11594 default:
11595 89 misc=0;
11596 89 break;
11597 }
11598
11599 40153 watch=w;
11600 56374 }
11601
11602 3 void eWallM::grabhero()
11603 {
11604 3 hashero=true;
11605 3 superman=1;
11606 3 }
11607
11608 206232 void eWallM::draw(BITMAP *dest)
11609 {
11610 206232 dummy_bool[1]=hashero;
11611 206232 update_enemy_frame();
11612
11613
4/6
✓ Branch 0 taken 145411 times.
✓ Branch 1 taken 60821 times.
✓ Branch 2 taken 145411 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 145411 times.
206232 if(misc>0 || fallclk||drownclk)
11614 {
11615 60821 masked_draw(dest,16,playing_field_offset+16,224,144);
11616 60821 }
11617
11618 // enemy::draw(dest);
11619 // tile = clk&8 ? 128:129;
11620 206232 }
11621
11622 bool eWallM::isSubmerged() const
11623 {
11624 return ( !misc );
11625 }
11626
11627 668 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11628 668 {
11629
1/2
✓ Branch 0 taken 334 times.
✗ Branch 1 not taken.
334 ox=x; //original x
11630
1/2
✓ Branch 0 taken 334 times.
✗ Branch 1 not taken.
334 oy=y; //original y
11631
3/4
✓ Branch 0 taken 334 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 268 times.
334 if(get_bit(quest_rules,qr_TRAPPOSFIX))
11632 {
11633
3/6
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 66 times.
✓ Branch 4 taken 66 times.
✗ Branch 5 not taken.
66 yofs = (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
11634 66 }
11635
11636 334 mainguy=false;
11637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
11638 //nets+420;
11639 334 dummy_int[1]=0;
11640 334 SIZEflags = d->SIZEflags;
11641
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
334 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11642 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
11643 // al_trace("Enemy txsz:%i\n", txsz);
11644
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
334 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
11645
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
334 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
11646
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
334 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
11647
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
334 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
11648
1/2
✓ Branch 0 taken 334 times.
✗ Branch 1 not taken.
334 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
11649
1/2
✓ Branch 0 taken 334 times.
✗ Branch 1 not taken.
334 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
11650 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
11651
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
334 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
11652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
11653 {
11654 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11655 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
11656 }
11657
11658
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
334 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
11659 334 }
11660
11661 271856 bool eTrap::animate(int32_t index)
11662 {
11663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 271856 times.
271856 if(switch_hooked) return enemy::animate(index);
11664
2/4
✓ Branch 0 taken 271856 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 271856 times.
271856 if(fallclk||drownclk) return enemy::animate(index);
11665
2/2
✓ Branch 0 taken 267180 times.
✓ Branch 1 taken 4676 times.
271856 if(clk<0)
11666 4676 return enemy::animate(index);
11667
11668
2/2
✓ Branch 0 taken 250310 times.
✓ Branch 1 taken 16870 times.
267180 if(clk==0)
11669 {
11670 16870 removearmos(x,y,ffcactivated);
11671 16870 }
11672
11673
2/2
✓ Branch 0 taken 66125 times.
✓ Branch 1 taken 201055 times.
267180 if(misc==0) // waiting
11674 {
11675 201055 ox = x;
11676 201055 oy = y;
11677 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11678 201055 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11679
11680
4/4
✓ Branch 0 taken 64668 times.
✓ Branch 1 taken 136387 times.
✓ Branch 2 taken 38797 times.
✓ Branch 3 taken 25871 times.
201055 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
11681 {
11682 25871 dir=down;
11683 25871 }
11684
4/4
✓ Branch 0 taken 117829 times.
✓ Branch 1 taken 57355 times.
✓ Branch 2 taken 38797 times.
✓ Branch 3 taken 79032 times.
175184 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
11685 {
11686 79032 dir=right;
11687 79032 }
11688
4/4
✓ Branch 0 taken 60520 times.
✓ Branch 1 taken 35632 times.
✓ Branch 2 taken 38797 times.
✓ Branch 3 taken 21723 times.
96152 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
11689 {
11690 21723 dir=up;
11691 21723 }
11692 else
11693 {
11694 74429 dir=left;
11695 }
11696
11697 201055 int32_t d2=lined_up(15,true);
11698
11699
4/4
✓ Branch 0 taken 67498 times.
✓ Branch 1 taken 133557 times.
✓ Branch 2 taken 386709 times.
✓ Branch 3 taken 185654 times.
331780 if(((d2<left || d2 > right) && (dmisc1==1)) ||
11700
2/2
✓ Branch 0 taken 64864 times.
✓ Branch 1 taken 120790 times.
185654 ((d2>down) && (dmisc1==2)) ||
11701
2/2
✓ Branch 0 taken 62487 times.
✓ Branch 1 taken 58303 times.
120790 ((d2>right) && (!dmisc1)) ||
11702
2/2
✓ Branch 0 taken 130725 times.
✓ Branch 1 taken 9935 times.
120790 ((d2<l_up) && (dmisc1==4)) ||
11703
3/4
✓ Branch 0 taken 130725 times.
✓ Branch 1 taken 120790 times.
✓ Branch 2 taken 130725 times.
✗ Branch 3 not taken.
9935 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
11704
3/4
✓ Branch 0 taken 130725 times.
✓ Branch 1 taken 9935 times.
✓ Branch 2 taken 130725 times.
✗ Branch 3 not taken.
120790 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
11705 {
11706 843748 d2=-1;
11707 843748 }
11708
11709
4/4
✓ Branch 0 taken 7368 times.
✓ Branch 1 taken 72897 times.
✓ Branch 2 taken 6867 times.
✓ Branch 3 taken 501 times.
80265 if(d2!=-1 && trapmove(d2))
11710 {
11711 501 dir=d2;
11712 501 misc=1;
11713 501 clk2=(dir==down)?3:0;
11714 501 }
11715 80265 }
11716
11717
2/2
✓ Branch 0 taken 128154 times.
✓ Branch 1 taken 18236 times.
146390 if(misc==1) // charging
11718 {
11719 18236 clk2=(clk2+1)&3;
11720 18236 step=(clk2==3)?1:2;
11721
11722
4/4
✓ Branch 0 taken 18232 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 456 times.
✓ Branch 3 taken 17776 times.
18236 if(!trapmove(dir) || clip())
11723 {
11724 460 misc=2;
11725
11726
1/2
✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
460 if(dir<l_up)
11727 {
11728 460 dir=dir^1;
11729 460 }
11730 else
11731 {
11732 dir=dir^3;
11733 }
11734 460 }
11735 else
11736 {
11737 17776 sprite::move(step);
11738 }
11739 18236 }
11740
11741
2/2
✓ Branch 0 taken 97540 times.
✓ Branch 1 taken 48850 times.
146390 if(misc==2) // retreating
11742 {
11743 48850 step=(++clk2&1)?1:0;
11744
11745
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5092 times.
✓ Branch 2 taken 19011 times.
✓ Branch 3 taken 5383 times.
✓ Branch 4 taken 19364 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
48850 switch(dir)
11746 {
11747 case up:
11748
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 5046 times.
5092 if(int32_t(y)<=oy) goto trap_rest;
11749 5046 else sprite::move(step);
11750
11751 5046 break;
11752
11753 case left:
11754
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 18905 times.
19011 if(int32_t(x)<=ox) goto trap_rest;
11755 18905 else sprite::move(step);
11756
11757 18905 break;
11758
11759 case down:
11760
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 5327 times.
5383 if(int32_t(y)>=oy) goto trap_rest;
11761 5327 else sprite::move(step);
11762
11763 5327 break;
11764
11765 case right:
11766
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 19249 times.
19364 if(int32_t(x)>=ox) goto trap_rest;
11767 19249 else sprite::move(step);
11768
11769 19249 break;
11770
11771 case l_up:
11772 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
11773 else sprite::move(step);
11774
11775 break;
11776
11777 case r_up:
11778 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
11779 else sprite::move(step);
11780
11781 break;
11782
11783 case l_down:
11784 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
11785 else sprite::move(step);
11786
11787 break;
11788
11789 case r_down:
11790 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
11791 else sprite::move(step);
11792
11793 break;
11794 trap_rest:
11795 {
11796 323 x=ox;
11797 323 y=oy;
11798 323 misc=0;
11799 }
11800 323 }
11801 48850 }
11802
11803 146390 return enemy::animate(index);
11804 151066 }
11805
11806 25604 bool eTrap::trapmove(int32_t ndir)
11807 {
11808
2/2
✓ Branch 0 taken 11337 times.
✓ Branch 1 taken 14267 times.
25604 if(get_bit(quest_rules,qr_MEANTRAPS))
11809 {
11810
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 10833 times.
11337 if(tmpscr->flags2&fFLOATTRAPS)
11811 504 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
11812
11813 10833 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
11814 }
11815
11816
6/6
✓ Branch 0 taken 6244 times.
✓ Branch 1 taken 8023 times.
✓ Branch 2 taken 4374 times.
✓ Branch 3 taken 1870 times.
✓ Branch 4 taken 1608 times.
✓ Branch 5 taken 2766 times.
14267 if(oy==80 && !(ndir==left || ndir == right))
11817 2766 return false;
11818
11819
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11501 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11501 if(ox==128 && !(ndir==up || ndir==down))
11820 return false;
11821
11822
3/4
✓ Branch 0 taken 4333 times.
✓ Branch 1 taken 7168 times.
✓ Branch 2 taken 4333 times.
✗ Branch 3 not taken.
11501 if(oy<80 && ndir==up)
11823 return false;
11824
11825
3/4
✓ Branch 0 taken 3690 times.
✓ Branch 1 taken 7811 times.
✓ Branch 2 taken 3690 times.
✗ Branch 3 not taken.
11501 if(oy>80 && ndir==down)
11826 return false;
11827
11828
4/4
✓ Branch 0 taken 5854 times.
✓ Branch 1 taken 5647 times.
✓ Branch 2 taken 5136 times.
✓ Branch 3 taken 718 times.
11501 if(ox<128 && ndir==left)
11829 718 return false;
11830
11831
4/4
✓ Branch 0 taken 5647 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 5159 times.
✓ Branch 3 taken 488 times.
10783 if(ox>128 && ndir==right)
11832 488 return false;
11833
11834
5/6
✓ Branch 0 taken 5136 times.
✓ Branch 1 taken 5159 times.
✓ Branch 2 taken 2207 times.
✓ Branch 3 taken 2929 times.
✓ Branch 4 taken 2207 times.
✗ Branch 5 not taken.
10295 if(ox<128 && oy<80 && ndir==l_up)
11835 return false;
11836
11837
5/6
✓ Branch 0 taken 5136 times.
✓ Branch 1 taken 5159 times.
✓ Branch 2 taken 1809 times.
✓ Branch 3 taken 3327 times.
✓ Branch 4 taken 1809 times.
✗ Branch 5 not taken.
10295 if(ox<128 && oy>80 && ndir==l_down)
11838 return false;
11839
11840
5/6
✓ Branch 0 taken 5159 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 2126 times.
✓ Branch 3 taken 3033 times.
✓ Branch 4 taken 2126 times.
✗ Branch 5 not taken.
10295 if(ox>128 && oy<80 && ndir==r_up)
11841 return false;
11842
11843
5/6
✓ Branch 0 taken 5159 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 1881 times.
✓ Branch 3 taken 3278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1881 times.
10295 if(ox>128 && oy>80 && ndir==r_down)
11844 return false;
11845
11846 10295 return true;
11847 25604 }
11848
11849 18232 bool eTrap::clip()
11850 {
11851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18232 times.
18232 if(get_bit(quest_rules,qr_MEANPLACEDTRAPS))
11852 {
11853 switch(dir)
11854 {
11855 case up:
11856 if(y<=0) return true;
11857
11858 break;
11859
11860 case down:
11861 if(y>=160) return true;
11862
11863 break;
11864
11865 case left:
11866 if(x<=0) return true;
11867
11868 break;
11869
11870 case right:
11871 if(x>=240) return true;
11872
11873 break;
11874
11875 case l_up:
11876 if(y<=0||x<=0) return true;
11877
11878 break;
11879
11880 case l_down:
11881 if(y>=160||x<=0) return true;
11882
11883 break;
11884
11885 case r_up:
11886 if(y<=0||x>=240) return true;
11887
11888 break;
11889
11890 case r_down:
11891 if(y>=160||x>=240) return true;
11892
11893 break;
11894 }
11895
11896 return false;
11897 }
11898 else
11899 {
11900
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 2082 times.
✓ Branch 2 taken 1825 times.
✓ Branch 3 taken 7103 times.
✓ Branch 4 taken 7222 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
18232 switch(dir)
11901 {
11902 case up:
11903
4/4
✓ Branch 0 taken 2028 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 1953 times.
✓ Branch 3 taken 75 times.
2082 if(oy>80 && y<=86) return true;
11904
11905 2007 break;
11906
11907 case down:
11908
4/4
✓ Branch 0 taken 1798 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 1736 times.
✓ Branch 3 taken 62 times.
1825 if(oy<80 && y>=80) return true;
11909
11910 1763 break;
11911
11912 case left:
11913
4/4
✓ Branch 0 taken 7085 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6927 times.
✓ Branch 3 taken 158 times.
7103 if(ox>128 && x<=124) return true;
11914
11915 6945 break;
11916
11917 case right:
11918
3/4
✓ Branch 0 taken 7222 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7061 times.
✓ Branch 3 taken 161 times.
7222 if(ox<120 && x>=116) return true;
11919
11920 7061 break;
11921
11922 case l_up:
11923 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
11924
11925 break;
11926
11927 case l_down:
11928 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
11929
11930 break;
11931
11932 case r_up:
11933 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
11934
11935 break;
11936
11937 case r_down:
11938 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
11939
11940 break;
11941 }
11942
11943 17776 return false;
11944 }
11945 18232 }
11946
11947 272174 void eTrap::draw(BITMAP *dest)
11948 {
11949 272174 update_enemy_frame();
11950 272174 enemy::draw(dest);
11951 272174 }
11952
11953 1799 int32_t eTrap::takehit(weapon*)
11954 {
11955 1799 return 0;
11956 }
11957
11958 8 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11959 8 {
11960 4 lasthit=-1;
11961 4 lasthitclk=0;
11962 4 mainguy=false;
11963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
11964
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 step=2;
11965
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
11966 {
11967
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 dir=(x<=112)?right:left;
11968 4 }
11969 else
11970 {
11971 dir=(y<=72)?down:up;
11972 }
11973
11974
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(get_bit(quest_rules,qr_TRAPPOSFIX))
11975 {
11976 yofs = (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
11977 }
11978
11979 //nets+((id==eTRAP_LR)?540:520);
11980 4 dummy_int[1]=0;
11981 4 SIZEflags = d->SIZEflags;
11982
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11983 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
11984 // al_trace("Enemy txsz:%i\n", txsz);
11985
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
11986
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
11987
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
11988
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
11989
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
11990
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
11991 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
11992
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
11993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
11994 {
11995 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11996 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
11997 }
11998
11999
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
12000 4 }
12001
12002 4448 bool eTrap2::animate(int32_t index)
12003 {
12004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4448 times.
4448 if(switch_hooked) return enemy::animate(index);
12005
2/4
✓ Branch 0 taken 4448 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4448 times.
4448 if(fallclk||drownclk) return enemy::animate(index);
12006
2/2
✓ Branch 0 taken 4392 times.
✓ Branch 1 taken 56 times.
4448 if(clk<0)
12007 56 return enemy::animate(index);
12008
12009
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 4116 times.
4392 if(clk==0)
12010 {
12011 276 removearmos(x,y,ffcactivated);
12012 276 }
12013
12014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4392 times.
4392 if(!get_bit(quest_rules,qr_PHANTOMPLACEDTRAPS))
12015 {
12016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4392 times.
4392 if(lasthitclk>0)
12017 {
12018 --lasthitclk;
12019 }
12020 else
12021 {
12022 4392 lasthit=-1;
12023 }
12024
12025 4392 bool hitenemy=false;
12026
12027
2/2
✓ Branch 0 taken 57096 times.
✓ Branch 1 taken 4392 times.
61488 for(int32_t j=0; j<guys.Count(); j++)
12028 {
12029
3/4
✓ Branch 0 taken 52704 times.
✓ Branch 1 taken 4392 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 52704 times.
57096 if((j!=index) && (lasthit!=j))
12030 {
12031
1/2
✓ Branch 0 taken 52704 times.
✗ Branch 1 not taken.
52704 if(hit(guys.spr(j)))
12032 {
12033 lasthit=j;
12034 lasthitclk=10;
12035 hitenemy=true;
12036 guys.spr(j)->lasthit=index;
12037 guys.spr(j)->lasthitclk=10;
12038 // guys.spr(j)->dir=guys.spr(j)->dir^1;
12039 }
12040 52704 }
12041 57096 }
12042
12043
4/6
✓ Branch 0 taken 4344 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 4344 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4344 times.
4392 if(!trapmove(dir) || clip() || hitenemy)
12044 {
12045
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if(!trapmove(dir) || clip())
12046 {
12047 48 lasthit=-1;
12048 48 lasthitclk=0;
12049 48 }
12050
12051
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(get_bit(quest_rules,qr_MORESOUNDS))
12052 sfx(WAV_ZN1TAP,pan(int32_t(x)));
12053
12054 48 dir=dir^1;
12055 48 }
12056
12057 4392 sprite::move(step);
12058 4392 }
12059 else
12060 {
12061 if(!trapmove(dir) || clip())
12062 {
12063 if(get_bit(quest_rules,qr_MORESOUNDS))
12064 sfx(WAV_ZN1TAP,pan(int32_t(x)));
12065
12066 dir=dir^1;
12067 }
12068
12069 sprite::move(step);
12070 }
12071
12072 4392 return enemy::animate(index);
12073 4448 }
12074
12075 4440 bool eTrap2::trapmove(int32_t ndir)
12076 {
12077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(tmpscr->flags2&fFLOATTRAPS)
12078 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
12079
12080 4440 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
12081 4440 }
12082
12083 4344 bool eTrap2::clip()
12084 {
12085
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2078 times.
✓ Branch 4 taken 2266 times.
4344 switch(dir)
12086 {
12087 case up:
12088 if(y<=0) return true;
12089
12090 break;
12091
12092 case down:
12093 if(y>=160) return true;
12094
12095 break;
12096
12097 case left:
12098
1/2
✓ Branch 0 taken 2078 times.
✗ Branch 1 not taken.
2078 if(x<=0) return true;
12099
12100 2078 break;
12101
12102 case right:
12103
1/2
✓ Branch 0 taken 2266 times.
✗ Branch 1 not taken.
2266 if(x>=240) return true;
12104
12105 2266 break;
12106 }
12107
12108 4344 return false;
12109 4344 }
12110
12111 4448 void eTrap2::draw(BITMAP *dest)
12112 {
12113 4448 update_enemy_frame();
12114 4448 enemy::draw(dest);
12115 4448 }
12116
12117 136 int32_t eTrap2::takehit(weapon*)
12118 {
12119 136 return 0;
12120 }
12121
12122 308 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12123 308 {
12124 //do not show "enemy appering" anim -DD
12125 154 clk=0;
12126 154 mainguy=false;
12127 154 clk2=-14;
12128 //Enemy Editor Size Tab
12129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
154 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12130 154 else hxofs = -2;
12131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
154 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12132 154 else hyofs = -2;
12133
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
154 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
12134 154 else hxsz = 20;
12135
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
154 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hysz = d->hysz;
12136 154 else hysz=20;
12137
12138
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
154 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12139
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
154 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12140
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
154 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
12141
1/4
✓ Branch 0 taken 154 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
154 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
12142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
154 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12143 {
12144 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12145 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12146 }
12147
12148
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
154 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
12149 //nets+1640;
12150 154 }
12151
12152 45244 bool eRock::animate(int32_t index)
12153 {
12154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45244 times.
45244 if(switch_hooked) return enemy::animate(index);
12155
2/4
✓ Branch 0 taken 45244 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 45244 times.
45244 if(fallclk||drownclk) return enemy::animate(index);
12156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45244 times.
45244 if(dying)
12157 return Dead(index);
12158
12159
2/2
✓ Branch 0 taken 42289 times.
✓ Branch 1 taken 2955 times.
45244 if(clk==0)
12160 {
12161 2955 removearmos(x,y,ffcactivated);
12162 2955 }
12163
12164
2/2
✓ Branch 0 taken 44984 times.
✓ Branch 1 taken 260 times.
45244 if(++clk2==0) // start it
12165 {
12166 260 x=zc_oldrand()&0xF0;
12167 260 y=0;
12168 260 clk3=0;
12169 260 clk2=zc_oldrand()&15;
12170 260 }
12171
12172
2/2
✓ Branch 0 taken 8209 times.
✓ Branch 1 taken 37035 times.
45244 if(clk2>16) // move it
12173 {
12174
2/2
✓ Branch 0 taken 35754 times.
✓ Branch 1 taken 1281 times.
37035 if(clk3<=0) // start bounce
12175 {
12176 1281 dir=zc_oldrand()&1;
12177
12178
2/2
✓ Branch 0 taken 1128 times.
✓ Branch 1 taken 153 times.
1281 if(x<32) dir=1;
12179
12180
2/2
✓ Branch 0 taken 1172 times.
✓ Branch 1 taken 109 times.
1281 if(x>208) dir=0;
12181 1281 }
12182
12183
2/2
✓ Branch 0 taken 35850 times.
✓ Branch 1 taken 1185 times.
37035 if(clk3<13+16)
12184 {
12185 35850 x += dir ? 1 : -1; //right, left
12186 35850 dummy_int[1]=dir;
12187
12188
2/2
✓ Branch 0 taken 2559 times.
✓ Branch 1 taken 33291 times.
35850 if(clk3<2)
12189 {
12190 2559 y-=2; //up
12191 2559 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
12192 2559 }
12193
2/2
✓ Branch 0 taken 3808 times.
✓ Branch 1 taken 29483 times.
33291 else if(clk3<5)
12194 {
12195 3808 y--; //up
12196 3808 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
12197 3808 }
12198
2/2
✓ Branch 0 taken 3785 times.
✓ Branch 1 taken 25698 times.
29483 else if(clk3<8)
12199 {
12200 3785 dummy_int[2]=(dummy_int[1]==1)?right:left;
12201 3785 }
12202
2/2
✓ Branch 0 taken 3757 times.
✓ Branch 1 taken 21941 times.
25698 else if(clk3<11)
12203 {
12204 3757 y++; //down
12205 3757 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
12206 3757 }
12207 else
12208 {
12209 21941 y+=2; //down
12210 21941 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
12211 }
12212
12213 35850 ++clk3;
12214 35850 }
12215
2/2
✓ Branch 0 taken 1034 times.
✓ Branch 1 taken 151 times.
1185 else if(y<176)
12216 1034 clk3=0; // next bounce
12217 else
12218 151 clk2 = -(zc_oldrand()&63); // back to top
12219 37035 }
12220
12221 45244 return enemy::animate(index);
12222 45244 }
12223
12224 8004 void eRock::drawshadow(BITMAP *dest, bool translucent)
12225 {
12226
2/2
✓ Branch 0 taken 1017 times.
✓ Branch 1 taken 6987 times.
8004 if(clk2>=0)
12227 {
12228 6987 int32_t tempy=yofs;
12229 6987 flip = 0;
12230 6987 int32_t fdiv = frate/4;
12231
1/2
✓ Branch 0 taken 6987 times.
✗ Branch 1 not taken.
6987 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
12232
1/2
✓ Branch 0 taken 6987 times.
✗ Branch 1 not taken.
6987 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
12233 6987 efrate:((clk>=(frate>>1))?1:0);
12234 6987 shadowtile = wpnsbuf[spr_shadow].tile+f2;
12235
12236 6987 yofs+=8;
12237
5/6
✓ Branch 0 taken 3278 times.
✓ Branch 1 taken 3709 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6987 times.
✓ Branch 4 taken 3278 times.
✓ Branch 5 taken 3709 times.
6987 yofs+=zc_max(0,zc_min(29-clk3,clk3));
12238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6987 times.
6987 if(!shadow_overpit(this))
12239 6987 enemy::drawshadow(dest, translucent);
12240 6987 yofs=tempy;
12241 6987 }
12242 8004 }
12243
12244 45296 void eRock::draw(BITMAP *dest)
12245 {
12246
4/6
✓ Branch 0 taken 6072 times.
✓ Branch 1 taken 39224 times.
✓ Branch 2 taken 6072 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6072 times.
45296 if(clk2>=0 || fallclk||drownclk)
12247 {
12248 39224 int32_t tempdir=dir;
12249 39224 dir=dummy_int[2];
12250 39224 update_enemy_frame();
12251 39224 enemy::draw(dest);
12252 39224 dir=tempdir;
12253 39224 }
12254 45296 }
12255
12256 596 int32_t eRock::takehit(weapon*)
12257 {
12258 596 return 0;
12259 }
12260
12261 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12262 {
12263 clk=0;
12264 mainguy=false;
12265 clk2=-14;
12266 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12267 else hxofs= -10;
12268 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12269 else hyofs=-10;
12270 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
12271 else hxsz=36;
12272 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hysz = d->hysz;
12273 else hysz=36;
12274 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
12275 else hzsz=16; //can't be jumped
12276
12277 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12278 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12279 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
12280 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
12281 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12282 {
12283 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12284 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12285 }
12286
12287 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
12288 //nets+1680;
12289 }
12290
12291 bool eBoulder::animate(int32_t index)
12292 {
12293 if(switch_hooked) return enemy::animate(index);
12294 if(fallclk||drownclk) return enemy::animate(index);
12295 if(dying)
12296 return Dead(index);
12297
12298 if(clk==0)
12299 {
12300 removearmos(x,y,ffcactivated);
12301 }
12302
12303 zfix *vert;
12304 vert = (moveflags & FLAG_USE_FAKE_Z) ? &fakez : get_bit(quest_rules,qr_ENEMIESZAXIS) ? &z : &y;
12305
12306 if(++clk2==0) // start it
12307 {
12308 x=zc_oldrand()&0xF0;
12309 y=-32;
12310 clk3=0;
12311 clk2=zc_oldrand()&15;
12312 }
12313
12314 if(clk2>16) // move it
12315 {
12316 if(clk3<=0) // start bounce
12317 {
12318 dir=zc_oldrand()&1;
12319
12320 if(x<32) dir=1;
12321
12322 if(x>208) dir=0;
12323 }
12324
12325 if(clk3<13+16)
12326 {
12327 x += dir ? 1 : -1; //right, left
12328 dummy_int[1]=dir;
12329
12330 if(clk3<2)
12331 {
12332 y-=2; //up
12333 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
12334 }
12335 else if(clk3<5)
12336 {
12337 y--; //up
12338 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
12339 }
12340 else if(clk3<8)
12341 {
12342 dummy_int[2]=(dummy_int[1]==1)?right:left;
12343 }
12344 else if(clk3<11)
12345 {
12346 y++; //down
12347 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
12348 }
12349 else
12350 {
12351 y+=2; //down
12352 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
12353 }
12354
12355 ++clk3;
12356 }
12357 else if(y<176)
12358 clk3=0; // next bounce
12359 else
12360 clk2 = -(zc_oldrand()&63); // back to top
12361 }
12362
12363 return enemy::animate(index);
12364 }
12365
12366 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
12367 {
12368 if(clk2>=0)
12369 {
12370 int32_t tempy=yofs;
12371 flip = 0;
12372 int32_t f2=((clk<<2)/frate)<<1;
12373 shadowtile = wpnsbuf[spr_shadow].tile+f2;
12374 yofs+=zc_max(0,zc_min(29-clk3,clk3));
12375
12376 yofs+=8;
12377 xofs-=8;
12378 if(!shadow_overpit(this))
12379 enemy::drawshadow(dest, translucent);
12380 xofs+=16;
12381 ++shadowtile;
12382 if(!shadow_overpit(this))
12383 enemy::drawshadow(dest, translucent);
12384 yofs+=16;
12385 shadowtile+=20;
12386 if(!shadow_overpit(this))
12387 enemy::drawshadow(dest, translucent);
12388 xofs-=16;
12389 --shadowtile;
12390 if(!shadow_overpit(this))
12391 enemy::drawshadow(dest, translucent);
12392 xofs+=8;
12393 yofs=tempy;
12394 }
12395 }
12396
12397 void eBoulder::draw(BITMAP *dest)
12398 {
12399 if(clk2>=0 || fallclk||drownclk)
12400 {
12401 int32_t tempdir=dir;
12402 dir=dummy_int[2];
12403 update_enemy_frame();
12404 dir=tempdir;
12405 xofs-=8;
12406 yofs-=8;
12407 drawblock(dest,15);
12408 xofs+=8;
12409 yofs+=8;
12410 // enemy::draw(dest);
12411 }
12412 }
12413
12414 int32_t eBoulder::takehit(weapon*)
12415 {
12416 return 0;
12417 }
12418
12419 2924 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
12420
3/4
✓ Branch 0 taken 1462 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 425 times.
✓ Branch 3 taken 1037 times.
1462 minRange(get_bit(quest_rules, qr_BROKENSTATUES) ? 0 : Clk)
12421 2924 {
12422 /* fixing
12423 hp=1;
12424 */
12425 1462 mainguy=false;
12426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1462 times.
1462 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12427 1462 hclk=clk; // the "no fire" range
12428 1462 clk=0;
12429 1462 clk3=96;
12430 1462 timer=0;
12431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1462 times.
1462 if(o_tile==0)
12432 {
12433 1462 superman=1;
12434 1462 hxofs=1000;
12435 1462 }
12436 1462 SIZEflags = d->SIZEflags;
12437
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1462 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1462 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12438 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12439 // al_trace("Enemy txsz:%i\n", txsz);
12440
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1462 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1462 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12441
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1462 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1462 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
12442
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1462 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1462 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
12443
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1462 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1462 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12444
1/2
✓ Branch 0 taken 1462 times.
✗ Branch 1 not taken.
1462 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12445
1/2
✓ Branch 0 taken 1462 times.
✗ Branch 1 not taken.
1462 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12446 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12447
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1462 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1462 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1462 times.
1462 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12449 {
12450 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12451 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12452 }
12453
12454
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1462 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1462 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
12455 1462 }
12456
12457 1089277 bool eProjectile::animate(int32_t index)
12458 {
12459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1089277 times.
1089277 if(switch_hooked) return enemy::animate(index);
12460
2/4
✓ Branch 0 taken 1089277 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1089277 times.
1089277 if(fallclk||drownclk) return enemy::animate(index);
12461
2/2
✓ Branch 0 taken 1084325 times.
✓ Branch 1 taken 4952 times.
1089277 if(clk==0)
12462 {
12463 4952 removearmos(x,y,ffcactivated);
12464 4952 }
12465
12466 double _MSVC2022_tmp1, _MSVC2022_tmp2;
12467 1089277 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
12468
12469
4/4
✓ Branch 0 taken 355915 times.
✓ Branch 1 taken 733362 times.
✓ Branch 2 taken 196652 times.
✓ Branch 3 taken 159263 times.
1089277 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
12470 {
12471 159263 dir=down;
12472 159263 }
12473
4/4
✓ Branch 0 taken 600169 times.
✓ Branch 1 taken 329845 times.
✓ Branch 2 taken 196652 times.
✓ Branch 3 taken 403517 times.
930014 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
12474 {
12475 403517 dir=right;
12476 403517 }
12477
4/4
✓ Branch 0 taken 368093 times.
✓ Branch 1 taken 158404 times.
✓ Branch 2 taken 196652 times.
✓ Branch 3 taken 171441 times.
526497 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
12478 {
12479 171441 dir=up;
12480 171441 }
12481 else
12482 {
12483 355056 dir=left;
12484 }
12485
12486
3/4
✓ Branch 0 taken 1089277 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 570909 times.
✓ Branch 3 taken 518368 times.
1089277 if(!stunclk && ++clk3>80)
12487 {
12488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 518368 times.
518368 if(dmisc1==9) // Breath type
12489 {
12490 if(timer==0)
12491 {
12492 unsigned r=zc_oldrand();
12493
12494 if(!(r&63))
12495 {
12496 timer=zc_oldrand()%50+50;
12497 }
12498 }
12499
12500 if(timer>0)
12501 {
12502 if(timer%4==0)
12503 {
12504 FireBreath(false);
12505 }
12506
12507 if(--timer==0)
12508 {
12509 clk3=0;
12510 }
12511 }
12512 }
12513
12514 else // Not breath type
12515 {
12516 518368 unsigned r=zc_oldrand();
12517
12518
4/4
✓ Branch 0 taken 8062 times.
✓ Branch 1 taken 510306 times.
✓ Branch 2 taken 544 times.
✓ Branch 3 taken 7518 times.
518368 if(!(r&63) && !HeroInRange(minRange))
12519 {
12520 7518 FireWeapon();
12521
12522
2/4
✓ Branch 0 taken 5419 times.
✓ Branch 1 taken 2099 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7518 if(get_bit(quest_rules, qr_BROKENSTATUES)==0 &&
12523
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5419 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5419 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
12524 {
12525
2/2
✓ Branch 0 taken 5125 times.
✓ Branch 1 taken 294 times.
5419 if(!((r>>7)&15))
12526 {
12527 294 x-=4;
12528 294 FireWeapon();
12529 294 x+=4;
12530 294 }
12531 5419 }
12532
12533 7518 clk3=0;
12534 7518 }
12535 }
12536 518368 }
12537
12538 1089277 return enemy::animate(index);
12539 1089277 }
12540
12541 1091401 void eProjectile::draw(BITMAP *dest)
12542 {
12543 1091401 update_enemy_frame();
12544 1091401 enemy::draw(dest);
12545 1091401 }
12546
12547 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12548 {
12549 hxofs=1000;
12550 }
12551
12552 void eTrigger::draw(BITMAP *dest)
12553 {
12554 update_enemy_frame();
12555 enemy::draw(dest);
12556 }
12557
12558 void eTrigger::death_sfx()
12559 {
12560 //silent death
12561 }
12562
12563 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12564 {
12565 o_tile+=wpnsbuf[iwNPCs].tile;
12566 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12567 SIZEflags = d->SIZEflags;
12568 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12569 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12570 // al_trace("Enemy txsz:%i\n", txsz);
12571 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12572 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
12573 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
12574 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12575 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12576 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12577 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12578 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12579 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12580 {
12581 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12582 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12583 }
12584
12585 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
12586 }
12587
12588 bool eNPC::animate(int32_t index)
12589 {
12590 if(switch_hooked) return enemy::animate(index);
12591 if(dying)
12592 return Dead(index);
12593
12594 if(clk==0)
12595 {
12596 removearmos(x,y,ffcactivated);
12597 }
12598
12599 switch(dmisc2)
12600 {
12601 case 0:
12602 {
12603 double _MSVC2022_tmp1, _MSVC2022_tmp2;
12604 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
12605
12606 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
12607 {
12608 dir=down;
12609 }
12610
12611 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
12612 {
12613 dir=right;
12614 }
12615 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
12616 {
12617 dir=up;
12618 }
12619 else
12620 {
12621 dir=left;
12622 }
12623 }
12624 break;
12625
12626 case 1:
12627 halting_walk(rate, homing, 0, hrate, 48);
12628
12629 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
12630 {
12631 newdir(rate, homing, 0);
12632 clk2=48;
12633 ++misc;
12634 }
12635
12636 if(clk2==0)
12637 misc=0;
12638
12639 break;
12640 }
12641
12642 return enemy::animate(index);
12643 }
12644
12645 void eNPC::draw(BITMAP *dest)
12646 {
12647 update_enemy_frame();
12648 enemy::draw(dest);
12649 }
12650
12651 int32_t eNPC::takehit(weapon*)
12652 {
12653 return 0;
12654 }
12655
12656 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12657 {
12658 if(clk>0) // clk>0 when created by a Spinning Tile combo
12659 {
12660 o_tile=clk;
12661 cs=id>>12;
12662 }
12663
12664 id=id&0xFFF;
12665 clk=0;
12666 step=0;
12667 mainguy=false;
12668 SIZEflags = d->SIZEflags;
12669 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12670 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12671 // al_trace("Enemy txsz:%i\n", txsz);
12672 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12673 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
12674 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
12675 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12676 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12677 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12678 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12679 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12680 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12681 {
12682 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12683 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12684 }
12685
12686 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
12687 }
12688
12689 void eSpinTile::facehero()
12690 {
12691 if(Hero.x-x==0)
12692 {
12693 if (Hero.y + 8 < y)
12694 dir = up;
12695 else
12696 dir = down;
12697 }
12698 else
12699 {
12700 double _MSVC2022_tmp1, _MSVC2022_tmp2;
12701 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
12702
12703 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
12704 {
12705 dir=l_down;
12706 }
12707 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
12708 {
12709 dir=down;
12710 }
12711 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
12712 {
12713 dir=r_down;
12714 }
12715 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
12716 {
12717 dir=right;
12718 }
12719 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
12720 {
12721 dir=r_up;
12722 }
12723 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
12724 {
12725 dir=up;
12726 }
12727 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
12728 {
12729 dir=l_up;
12730 }
12731 else
12732 {
12733 dir=left;
12734 }
12735 }
12736 }
12737
12738
12739 bool eSpinTile::animate(int32_t index)
12740 {
12741 if(switch_hooked) return enemy::animate(index);
12742 if(fallclk||drownclk) return enemy::animate(index);
12743 if(dying)
12744 {
12745 return Dead(index);
12746 }
12747
12748 if(clk==0)
12749 {
12750 removearmos(x,y,ffcactivated);
12751 }
12752
12753 ++misc;
12754
12755 if(misc==96)
12756 {
12757 facehero();
12758 double _MSVC2022_tmp1, _MSVC2022_tmp2;
12759 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
12760 angular=true;
12761 angle=ddir;
12762 step=zslongToFix(dstep*100);
12763 }
12764
12765 if(y>186 || y<=-16 || x>272 || x<=-16)
12766 kickbucket();
12767
12768 sprite::move(step);
12769 return enemy::animate(index);
12770 }
12771
12772 void eSpinTile::draw(BITMAP *dest)
12773 {
12774 update_enemy_frame();
12775 y-=(misc>>4);
12776 yofs+=2;
12777 enemy::draw(dest);
12778 yofs-=2;
12779 y+=(misc>>4);
12780 }
12781
12782 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
12783 {
12784 flip = 0;
12785 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
12786 yofs+=4;
12787 if(!shadow_overpit(this))
12788 enemy::drawshadow(dest, translucent);
12789 yofs-=4;
12790 }
12791
12792 2172 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
12793 2172 {
12794 //these are here to bypass compiler warnings about unused arguments
12795 1086 Clk=Clk;
12796 1086 mainguy=false;
12797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1086 times.
1086 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12798 /*if((x>-17 && x<0) && iswaterex(tmpscr->data[(((int32_t)y&0xF0)+((int32_t)x>>4))]))
12799 {
12800 clk=1;
12801 }*/
12802 //nets+880;
12803 1086 SIZEflags = d->SIZEflags;
12804
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1086 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1086 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12805 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12806 // al_trace("Enemy txsz:%i\n", txsz);
12807
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1086 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1086 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12808
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1086 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1086 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
12809
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1086 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1086 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
12810
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1086 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1086 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12811
1/2
✓ Branch 0 taken 1086 times.
✗ Branch 1 not taken.
1086 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12812
1/2
✓ Branch 0 taken 1086 times.
✗ Branch 1 not taken.
1086 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12813 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12814
1/4
✓ Branch 0 taken 1086 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1086 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1086 times.
1086 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12816 {
12817 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12818 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12819 }
12820
12821
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1086 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1086 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
12822 1086 }
12823
12824 277431 void eZora::facehero()
12825 {
12826
2/2
✓ Branch 0 taken 4071 times.
✓ Branch 1 taken 273360 times.
277431 if(Hero.x-x==0)
12827 {
12828 4071 dir=(Hero.y+8<y)?up:down;
12829 4071 }
12830 else
12831 {
12832 double _MSVC2022_tmp1, _MSVC2022_tmp2;
12833 273360 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
12834
12835
4/4
✓ Branch 0 taken 60907 times.
✓ Branch 1 taken 212453 times.
✓ Branch 2 taken 23739 times.
✓ Branch 3 taken 37168 times.
273360 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
12836 {
12837 37168 dir=l_down;
12838 37168 }
12839
4/4
✓ Branch 0 taken 39532 times.
✓ Branch 1 taken 196660 times.
✓ Branch 2 taken 23739 times.
✓ Branch 3 taken 15793 times.
236192 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
12840 {
12841 15793 dir=down;
12842 15793 }
12843
4/4
✓ Branch 0 taken 53953 times.
✓ Branch 1 taken 166446 times.
✓ Branch 2 taken 23739 times.
✓ Branch 3 taken 30214 times.
220399 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
12844 {
12845 30214 dir=r_down;
12846 30214 }
12847
4/4
✓ Branch 0 taken 73021 times.
✓ Branch 1 taken 117164 times.
✓ Branch 2 taken 23739 times.
✓ Branch 3 taken 49282 times.
190185 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
12848 {
12849 49282 dir=right;
12850 49282 }
12851
4/4
✓ Branch 0 taken 59900 times.
✓ Branch 1 taken 81003 times.
✓ Branch 2 taken 23739 times.
✓ Branch 3 taken 36161 times.
140903 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
12852 {
12853 36161 dir=r_up;
12854 36161 }
12855
4/4
✓ Branch 0 taken 41580 times.
✓ Branch 1 taken 63162 times.
✓ Branch 2 taken 23739 times.
✓ Branch 3 taken 17841 times.
104742 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
12856 {
12857 17841 dir=up;
12858 17841 }
12859
4/4
✓ Branch 0 taken 59771 times.
✓ Branch 1 taken 27130 times.
✓ Branch 2 taken 36032 times.
✓ Branch 3 taken 23739 times.
86901 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
12860 {
12861 36032 dir=l_up;
12862 36032 }
12863 else
12864 {
12865 50869 dir=left;
12866 }
12867 }
12868 277431 }
12869
12870 395215 bool eZora::animate(int32_t index)
12871 {
12872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395215 times.
395215 if(switch_hooked) return enemy::animate(index);
12873
2/2
✓ Branch 0 taken 1800 times.
✓ Branch 1 taken 393415 times.
395215 if(dying)
12874 1800 return Dead(index);
12875
12876
2/2
✓ Branch 0 taken 390870 times.
✓ Branch 1 taken 2545 times.
393415 if(clk==0)
12877 {
12878 2545 removearmos(x,y,ffcactivated);
12879 2545 }
12880
12881
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 393389 times.
393415 if(watch)
12882 {
12883 26 ++clock_zoras[id];
12884 26 return true;
12885 }
12886
12887
2/2
✓ Branch 0 taken 115958 times.
✓ Branch 1 taken 277431 times.
393389 if(get_bit(quest_rules,qr_NEWENEMYTILES))
12888 {
12889 277431 facehero();
12890 277431 }
12891
12892
6/6
✓ Branch 0 taken 2352 times.
✓ Branch 1 taken 2259 times.
✓ Branch 2 taken 1899 times.
✓ Branch 3 taken 382297 times.
✓ Branch 4 taken 3115 times.
✓ Branch 5 taken 1467 times.
393389 switch(clk)
12893 {
12894 case 0: // reposition him
12895 {
12896 3115 int32_t t=0;
12897 3115 int32_t pos2=zc_oldrand()%160 + 16;
12898 3115 bool placed=false;
12899
12900
4/4
✓ Branch 0 taken 3092 times.
✓ Branch 1 taken 16538 times.
✓ Branch 2 taken 10901 times.
✓ Branch 3 taken 2545 times.
19630 while(!placed && t<160)
12901 {
12902 10901 int32_t watertype = iswaterex(tmpscr->data[pos2], currmap, currscr, -1, ((pos2)%16*16), ((pos2)&0xF0), false, true, true, (bool)(editorflags & ENEMY_FLAG7));
12903
5/6
✓ Branch 0 taken 3131 times.
✓ Branch 1 taken 7770 times.
✓ Branch 2 taken 3131 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 285 times.
✓ Branch 5 taken 2522 times.
13708 if(watertype && ((editorflags & ENEMY_FLAG6) ||
12904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3131 times.
3131 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
12905
3/4
✓ Branch 0 taken 3131 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2807 times.
✓ Branch 3 taken 2807 times.
3131 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
12906 {
12907 2522 x=(pos2&15)<<4;
12908 2522 y=pos2&0xF0;
12909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2522 times.
2522 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
12910 2522 hxofs=1000; // avoid hit detection
12911 2522 stunclk=0;
12912 2522 placed=true;
12913 2522 }
12914
12915 16515 pos2+=19;
12916
12917
2/2
✓ Branch 0 taken 14556 times.
✓ Branch 1 taken 1959 times.
16515 if(pos2>=176)
12918 1959 pos2-=160;
12919
12920 16515 ++t;
12921 }
12922
12923
3/4
✓ Branch 0 taken 2522 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2522 times.
2545 if(!placed || whistleclk>=88) // can't place him, he's gone
12924 23 return true;
12925
12926 }
12927 2522 break;
12928
12929 case 35:
12930
2/2
✓ Branch 0 taken 1662 times.
✓ Branch 1 taken 690 times.
2352 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
12931 {
12932 690 dir=(Hero.y+8<y)?up:down;
12933 690 }
12934
12935 2352 hxofs=0;
12936 2352 break;
12937
12938 case 35+19:
12939 2259 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
12940 2259 sfx(wpnsfx(wpn),pan(int32_t(x)));
12941 2259 break;
12942
12943 case 35+66:
12944 1899 hxofs=1000;
12945 1899 break;
12946
12947 case 198:
12948 1467 clk=-1;
12949 1467 break;
12950 }
12951
12952 392796 return enemy::animate(index);
12953 394645 }
12954
12955 394994 void eZora::draw(BITMAP *dest)
12956 {
12957
2/2
✓ Branch 0 taken 7579 times.
✓ Branch 1 taken 387415 times.
394994 if(clk<3)
12958 7579 return;
12959
12960 387415 update_enemy_frame();
12961 387415 enemy::draw(dest);
12962 394994 }
12963
12964 bool eZora::isSubmerged() const
12965 {
12966 return ( clk < 3 );
12967 }
12968
12969
4/8
✓ Branch 0 taken 10447 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10447 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10447 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10447 times.
✗ Branch 7 not taken.
31341 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12970 20894 {
12971 10447 multishot= timer = fired = dashing = 0;
12972 10447 hashero = false;
12973 10447 dummy_bool[0]=false;
12974 10447 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
12975
5/6
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 10392 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✓ Branch 5 taken 25 times.
10447 if(dmisc9==e9tARMOS && zc_oldrand()&1)
12976 {
12977
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 step=zslongToFix(dmisc10*100);
12978
12979
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 23 times.
30 if(anim==aARMOS4) o_tile+=20;
12980 30 }
12981
12982
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 10392 times.
10447 if(flags & guy_fadeflicker)
12983 {
12984 55 clk=0;
12985 55 superman = 1;
12986 55 fading=fade_flicker;
12987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12988 55 dir=down;
12989
12990
4/6
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 31 times.
55 if(!canmove(down,(zfix)8,spw_none,false))
12991
3/6
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
24 clk3=int32_t(13.0/step);
12992 55 }
12993
1/2
✓ Branch 0 taken 10392 times.
✗ Branch 1 not taken.
10392 else if(flags & guy_fadeinstant)
12994 {
12995 clk=0;
12996 }
12997
12998
1/2
✓ Branch 0 taken 10447 times.
✗ Branch 1 not taken.
10447 shadowdistance = 0;
12999 10447 clk4 = clk5 = 0;
13000 //nets+2380;
13001 10447 SIZEflags = d->SIZEflags;
13002
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 10447 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
10447 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13003 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13004 // al_trace("Enemy txsz:%i\n", txsz);
13005
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 10447 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
10447 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
13006
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10447 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10447 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
13007
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10447 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10447 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
13008
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10447 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10447 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
13009
1/2
✓ Branch 0 taken 10447 times.
✗ Branch 1 not taken.
10447 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
13010
1/2
✓ Branch 0 taken 10447 times.
✗ Branch 1 not taken.
10447 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
13011 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13012
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10447 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10447 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
13013
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10447 times.
10447 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13014 {
13015 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13016 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13017 }
13018
13019
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10447 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10447 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
13020 10447 }
13021
13022 4829643 bool eStalfos::animate(int32_t index)
13023 {
13024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4829643 times.
4829643 if(switch_hooked) return enemy::animate(index);
13025
2/4
✓ Branch 0 taken 4829643 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4829643 times.
4829643 if(fallclk||drownclk)
13026 {
13027 return enemy::animate(index);
13028 }
13029
2/2
✓ Branch 0 taken 106618 times.
✓ Branch 1 taken 4723025 times.
4829643 if(dying)
13030 {
13031
2/2
✓ Branch 0 taken 106596 times.
✓ Branch 1 taken 22 times.
106618 if(hashero)
13032 {
13033 22 Hero.setEaten(0);
13034 22 hashero=false;
13035 22 }
13036
13037
10/14
✓ Branch 0 taken 7740 times.
✓ Branch 1 taken 98878 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 7660 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 75 times.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 5 times.
106618 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
13038 {
13039 5 hp=-1000;
13040
5/10
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✗ Branch 9 not taken.
5 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
13041 5 Ewpns.add(ew);
13042 5 ew->fakez = fakez;
13043
13044
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(wpn==ewSBomb || wpn==ewBomb)
13045 {
13046 5 ew->step=0;
13047 5 ew->id=wpn;
13048 5 ew->misc=50;
13049 5 ew->clk=48;
13050 5 }
13051
13052 5 fired=true;
13053 5 }
13054
5/6
✓ Branch 0 taken 52090 times.
✓ Branch 1 taken 54523 times.
✓ Branch 2 taken 44604 times.
✓ Branch 3 taken 7486 times.
✓ Branch 4 taken 44604 times.
✗ Branch 5 not taken.
106613 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
13055 {
13056 if(!dummy_bool[0])
13057 {
13058 int32_t wpn2 = wpn+dmisc3;
13059
13060 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
13061 {
13062 wpn2=wpn;
13063 }
13064
13065 dummy_bool[0]=true;
13066 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
13067 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13068 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
13069 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13070 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
13071 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13072 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
13073 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13074 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
13075 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13076 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
13077 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13078 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
13079 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13080 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
13081 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13082 sfx(wpnsfx(wpn2),pan(int32_t(x)));
13083 }
13084 }
13085
13086 106618 KillWeapon();
13087 106618 return Dead(index);
13088 }
13089 //vire split
13090 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
13091 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
13092
13/14
✓ Branch 0 taken 6026 times.
✓ Branch 1 taken 4716999 times.
✓ Branch 2 taken 6026 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 97 times.
✓ Branch 5 taken 5929 times.
✓ Branch 6 taken 551677 times.
✓ Branch 7 taken 4171251 times.
✓ Branch 8 taken 550655 times.
✓ Branch 9 taken 1022 times.
✓ Branch 10 taken 2503 times.
✓ Branch 11 taken 548152 times.
✓ Branch 12 taken 480 times.
✓ Branch 13 taken 2023 times.
4723025 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
13093 {
13094 577 stop_bgsfx(index);
13095 577 int32_t kids = guys.Count();
13096 577 int32_t id2=dmisc3;
13097
2/2
✓ Branch 0 taken 1154 times.
✓ Branch 1 taken 577 times.
1731 for(int32_t i=0; i < dmisc4; i++)
13098 {
13099 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
13100
4/6
✓ Branch 0 taken 250 times.
✓ Branch 1 taken 904 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 904 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1154 times.
1154 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
13101 1154 ((enemy*)guys.spr(kids+i))->count_enemy = false;
13102 1154 }
13103
13104
1/2
✓ Branch 0 taken 577 times.
✗ Branch 1 not taken.
577 if(itemguy) // Hand down the carried item
13105 {
13106 guycarryingitem = guys.Count()-1;
13107 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13108 itemguy = false;
13109 }
13110
13111
1/2
✓ Branch 0 taken 577 times.
✗ Branch 1 not taken.
577 if(hashero)
13112 {
13113 Hero.setEaten(0);
13114 hashero=false;
13115 }
13116
13117
3/4
✓ Branch 0 taken 577 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✓ Branch 3 taken 97 times.
577 if(deadsfx > 0 && dmisc2==e2tSPLIT)
13118 97 sfx(deadsfx,pan(int32_t(x)));
13119
13120 577 return true;
13121 }
13122 /*
13123 else if((dmisc2==e2tSPLITHIT && (hp<=0 && !immortal) &&!slide())) //Possible vires fix; or could cause goodness knows what. -Z
13124 {
13125 stop_bgsfx(index);
13126 int32_t kids = guys.Count();
13127 int32_t id2=dmisc3;
13128
13129 for(int32_t i=0; i < dmisc4; i++)
13130 {
13131 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
13132 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : (i<<12)),-21-(i%4)))
13133 ((enemy*)guys.spr(kids+i))->count_enemy = false;
13134 }
13135
13136 if(itemguy) // Hand down the carried item
13137 {
13138 guycarryingitem = guys.Count()-1;
13139 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13140 itemguy = false;
13141 }
13142
13143 if(hashero)
13144 {
13145 Hero.setEaten(0);
13146 hashero=false;
13147 }
13148
13149 return true;
13150 }
13151 */
13152
2/2
✓ Branch 0 taken 3599 times.
✓ Branch 1 taken 4718849 times.
4722448 if(fading)
13153 {
13154
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 3543 times.
3599 if(++clk4 > 60)
13155 {
13156 56 clk4=0;
13157 56 superman=0;
13158 56 fading=0;
13159
13160
4/6
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 55 times.
56 if(flags2&cmbflag_armos && z==0 && fakez == 0)
13161 {
13162 //if a custom size (not 16px by 16px)
13163
13164 //if a custom size (not 16px by 16px)
13165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if (ffcactivated)
13166 removearmosffc(ffcactivated-1);
13167 else
13168 {
13169
4/8
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 55 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 55 times.
55 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
13170 {
13171 //zprint("spawn big enemy from armos\n");
13172 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
13173 for(int32_t dx = 0; dx < tysz; dx ++)
13174 {
13175 for(int32_t dy = 0; dy < tysz; dy++)
13176 {
13177 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
13178 did_armos = false;
13179 }
13180 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
13181 did_armos = false;
13182 }
13183 for(int32_t dy = 0; dy < tysz; dy ++)
13184 {
13185 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
13186 did_armos = false;
13187 }
13188 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
13189 }
13190 55 else removearmos(x,y);
13191 }
13192 /*
13193 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
13194 {
13195 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
13196 for(int32_t dx = 0; dx < hxsz; dx += 16)
13197 {
13198 for(int32_t dy = 0; dy < hysz; dy += 16)
13199 {
13200 removearmos((int32_t)x+dx+hxofs,(int32_t)y+dy+hyofs+1,ffcactivated);
13201 did_armos = false;
13202 }
13203 removearmos((int32_t)x+dx+hxofs, (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
13204 did_armos = false;
13205 }
13206 for(int32_t dy = 0; dy < hysz; dy += 16)
13207 {
13208 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+dy+hyofs-1,ffcactivated);
13209 did_armos = false;
13210 }
13211 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
13212 }
13213 else removearmos(x,y,ffcactivated);
13214 */
13215
13216 55 }
13217
13218 56 clk2=0;
13219
13220 56 newdir();
13221 56 }
13222 3543 else return enemy::animate(index);
13223 56 }
13224
6/8
✓ Branch 0 taken 4109 times.
✓ Branch 1 taken 4714740 times.
✓ Branch 2 taken 4109 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4109 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3839 times.
✓ Branch 7 taken 270 times.
4718849 else if(flags2&cmbflag_armos && z==0 && fakez == 0 && clk==0)
13225 270 removearmos(x,y,ffcactivated);
13226
13227
13228
2/2
✓ Branch 0 taken 1979 times.
✓ Branch 1 taken 4716926 times.
4718905 if(hashero)
13229 {
13230 1979 Hero.setX(x);
13231 1979 Hero.setY(y);
13232 1979 ++clk2;
13233
13234
4/4
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 1929 times.
✓ Branch 3 taken 50 times.
1979 if(clk2==(dmisc8==0 ? 95 : dmisc8))
13235 {
13236
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50 switch(dmisc7)
13237 {
13238 case e7tEATITEMS:
13239 {
13240 for(int32_t i=0; i<MAXITEMS; i++)
13241 {
13242 if(itemsbuf[i].flags&ITEM_EDIBLE)
13243 game->set_item(i, false);
13244 }
13245
13246 break;
13247 }
13248
13249 case e7tEATMAGIC:
13250 game->change_dmagic(-1*game->get_magicdrainrate());
13251 break;
13252
13253 case e7tEATRUPEES:
13254 game->change_drupy(-1);
13255 break;
13256 }
13257
13258 50 clk2=0;
13259 50 }
13260
13261
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 1850 times.
1979 if((clk&0x18)==8) // stop its animation on the middle frame
13262 1850 --clk;
13263 1979 }
13264
4/4
✓ Branch 0 taken 298412 times.
✓ Branch 1 taken 4418514 times.
✓ Branch 2 taken 167612 times.
✓ Branch 3 taken 130800 times.
4716926 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
13265 {
13266 // Movement engine
13267
4/6
✓ Branch 0 taken 199427 times.
✓ Branch 1 taken 4386699 times.
✓ Branch 2 taken 1688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4385011 times.
✗ Branch 5 not taken.
4586126 if(clk>=0) switch(id>>12)
13268 {
13269 case 0: // Normal movement
13270
13271 /*
13272 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
13273 {
13274 // Overloading clk4 (Tribble clock) here...
13275 step=17/100.0;
13276 if(clk4<32) misc=1;
13277 else if(clk4<48) misc=2;
13278 else if(clk4<300) { misc=3; step = dstep/100.0; }
13279 else if(clk4<316) misc=2;
13280 else if(clk4<412) misc=1;
13281 else if(clk4<540) { misc=0; step=0; }
13282 else clk4=0;
13283 if(clk4==48) clk=0;
13284 hxofs=(misc>=2)?0:1000;
13285 if (dmisc9==e9tLEEVER)
13286 variable_walk(rate, homing, 0);
13287 else
13288 variable_walk_8(rate, homing, 4, 0);
13289 break;
13290 }
13291 */
13292
4/4
✓ Branch 0 taken 4276667 times.
✓ Branch 1 taken 108344 times.
✓ Branch 2 taken 156930 times.
✓ Branch 3 taken 4119737 times.
4385011 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
13293 {
13294 265274 vire_hop();
13295 265274 break;
13296 }
13297
2/2
✓ Branch 0 taken 303504 times.
✓ Branch 1 taken 3816233 times.
4119737 else if(dmisc9==e9tROPE) //Rope charge
13298 {
13299
9/10
✓ Branch 0 taken 286082 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 54540 times.
✓ Branch 3 taken 231542 times.
✓ Branch 4 taken 49076 times.
✓ Branch 5 taken 5464 times.
✓ Branch 6 taken 48360 times.
✓ Branch 7 taken 716 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 48360 times.
303504 if(!fired && dashing && !stunclk && !watch && !frozenclock)
13300 {
13301
3/6
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 48245 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48360 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
13302 {
13303
13304 if ( get_bit(quest_rules,qr_BOMBCHUSUPERBOMB) )
13305 {
13306 hp=-1000;
13307
13308 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
13309 {
13310 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
13311 Ewpns.add(ew);
13312 ew->fakez = fakez;
13313
13314 if(wpn==ewSBomb || wpn==ewBomb)
13315 {
13316 ew->step=0;
13317 ew->id=wpn+dmisc3;
13318 ew->misc=50;
13319 ew->clk=48;
13320 }
13321
13322 fired=true;
13323 }
13324 else
13325 {
13326 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
13327 Ewpns.add(ew);
13328 ew->fakez = fakez;
13329
13330 if(wpn==ewSBomb || wpn==ewBomb)
13331 {
13332 ew->step=0;
13333 ew->id=wpn;
13334 ew->misc=50;
13335 ew->clk=48;
13336 }
13337
13338 fired=true;
13339 }
13340 }
13341
13342 else
13343 {
13344 hp=-1000;
13345
13346 int32_t wpn2;
13347 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
13348 wpn2=wpn;
13349 else
13350 wpn2=wpn;
13351
13352 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
13353 Ewpns.add(ew);
13354 ew->fakez = fakez;
13355
13356 if(wpn2==ewSBomb || wpn2==ewBomb)
13357 {
13358 ew->step=0;
13359 ew->id=wpn2;
13360 ew->misc=50;
13361 ew->clk=48;
13362 }
13363
13364 fired=true;
13365 }
13366 }
13367 48360 }
13368
13369 303504 charge_attack();
13370 303504 break;
13371 }
13372 /*
13373 * Boomerang-throwers have a halt count of 1
13374 * Zols have a halt count of (zc_oldrand()&7)<<4
13375 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
13376 * Everything else has 48
13377 */
13378 else
13379 {
13380
2/2
✓ Branch 0 taken 158428 times.
✓ Branch 1 taken 3657805 times.
3816233 if(wpn==ewBrang) // Goriya
13381 {
13382 158428 halting_walk(rate,homing,0,hrate, 1);
13383 158428 }
13384
4/4
✓ Branch 0 taken 3653641 times.
✓ Branch 1 taken 4164 times.
✓ Branch 2 taken 1200313 times.
✓ Branch 3 taken 2453328 times.
3657805 else if(dmisc9==e9tNORMAL && wpn==0)
13385 {
13386
2/2
✓ Branch 0 taken 420977 times.
✓ Branch 1 taken 2032351 times.
2453328 if(dmisc2==e2tSPLITHIT) // Zol
13387 {
13388 420977 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
13389 420977 }
13390
4/4
✓ Branch 0 taken 729438 times.
✓ Branch 1 taken 1302913 times.
✓ Branch 2 taken 686186 times.
✓ Branch 3 taken 43252 times.
2032351 else if(frate<=8 && starting_hp==1) // Gel
13391 {
13392 43252 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
13393 43252 }
13394 else // Other
13395 {
13396 1989099 halting_walk(rate,homing,0,hrate, 48);
13397 }
13398 2453328 }
13399 else // Other
13400 {
13401 1204477 halting_walk(rate,homing,0,hrate, 48);
13402 }
13403 }
13404
13405 //if not in midair, and Hero's swinging sword is nearby, jump.
13406 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
13407 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
13408 {
13409 facehero(false);
13410 sclk=16+((dir^1)<<8);
13411 fall=-FEATHERJUMP;
13412 sfx(WAV_ZN1JUMP,pan(int32_t(x)));
13413 }*/
13414 3816233 break;
13415
13416 // Following cases are for just after creation-by-splitting.
13417 case 1:
13418
2/2
✓ Branch 0 taken 1269 times.
✓ Branch 1 taken 419 times.
1688 if(misc==1)
13419 {
13420 419 dir=up;
13421 419 step=8;
13422 419 }
13423
13424
2/2
✓ Branch 0 taken 406 times.
✓ Branch 1 taken 1282 times.
1688 if(misc<=2)
13425 {
13426 1282 move(step);
13427
13428
2/2
✓ Branch 0 taken 1065 times.
✓ Branch 1 taken 217 times.
1282 if(!canmove(dir,(zfix)0,0,false))
13429 217 dir=down;
13430 1282 }
13431
13432
2/2
✓ Branch 0 taken 1282 times.
✓ Branch 1 taken 406 times.
1688 if(misc==3)
13433 {
13434
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 256 times.
406 if(canmove(right,(zfix)16,0,false))
13435 256 x+=16;
13436 406 }
13437
13438 1688 ++misc;
13439 1688 break;
13440
13441 case 2:
13442 if(misc==1)
13443 {
13444 dir=down;
13445 step=8;
13446 }
13447
13448 if(misc<=2)
13449 {
13450 move(step);
13451 /*
13452 if(!canmove(dir,(zfix)0,0,false))
13453 dir=up;
13454 */
13455 }
13456
13457 if(misc==3)
13458 {
13459 if(canmove(left,(zfix)16,0,false))
13460 x-=16;
13461 }
13462
13463 ++misc;
13464 break;
13465
13466 default:
13467 if(misc==1)
13468 {
13469 dir=(zc_oldrand()%4);
13470 step=8;
13471 }
13472
13473 if(misc<=2)
13474 {
13475 move(step);
13476
13477 if(!canmove(dir,(zfix)0,0,false))
13478 dir=dir^1;
13479 }
13480
13481 if(misc==3)
13482 {
13483 if(dir >= left && canmove(dir,(zfix)16,0,false))
13484 x+=(dir==left ? -16 : 16);
13485 }
13486
13487 ++misc;
13488 break;
13489 4386699 }
13490
13491
4/4
✓ Branch 0 taken 11632 times.
✓ Branch 1 taken 4574494 times.
✓ Branch 2 taken 11226 times.
✓ Branch 3 taken 406 times.
4586126 if(id>>12 && misc>=4) //recently spawned by a split enemy
13492 {
13493 406 id&=0xFFF;
13494 406 step = zslongToFix(dstep*100);
13495
13496
1/2
✓ Branch 0 taken 406 times.
✗ Branch 1 not taken.
406 if(x<32) x=32;
13497
13498
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 5 times.
406 if(x>208) x=208;
13499
13500
2/2
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 6 times.
406 if(y<32) y=32;
13501
13502
1/2
✓ Branch 0 taken 406 times.
✗ Branch 1 not taken.
406 if(y>128) y=128;
13503
13504 406 misc=3;
13505 406 }
13506 4586126 }
13507 else
13508 {
13509 //sfx(wpnsfx(wpn),pan(int32_t(x)));
13510
1/2
✓ Branch 0 taken 130800 times.
✗ Branch 1 not taken.
130800 if(clk2>2) clk2--;
13511 }
13512
13513 // Fire Zol
13514
3/8
✓ Branch 0 taken 1636822 times.
✓ Branch 1 taken 3082083 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1636822 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4718905 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
13515 {
13516 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
13517 sfx(wpnsfx(wpn),pan(int32_t(x)));
13518
13519 int32_t i=Ewpns.Count()-1;
13520 weapon *ew = (weapon*)(Ewpns.spr(i));
13521
13522 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
13523 {
13524 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
13525 if ( ew->do_animation ) ew->tile+=ew->aframe;
13526 }
13527 }
13528 // Goriya
13529
14/16
✓ Branch 0 taken 298412 times.
✓ Branch 1 taken 4420493 times.
✓ Branch 2 taken 143765 times.
✓ Branch 3 taken 154647 times.
✓ Branch 4 taken 139539 times.
✓ Branch 5 taken 4226 times.
✓ Branch 6 taken 127358 times.
✓ Branch 7 taken 12181 times.
✓ Branch 8 taken 127358 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 126132 times.
✓ Branch 11 taken 1226 times.
✓ Branch 12 taken 126132 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 124282 times.
✓ Branch 15 taken 1850 times.
4718905 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
13530 {
13531 1850 misc=index+100;
13532
7/14
✓ Branch 0 taken 1850 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1850 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1850 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1850 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1850 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1850 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1850 times.
✗ Branch 13 not taken.
1850 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
13533 1850 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
13534
13535
2/2
✓ Branch 0 taken 1799 times.
✓ Branch 1 taken 51 times.
1850 if(dmisc1==2)
13536 {
13537 51 int32_t ndir=dir;
13538
13539
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 47 times.
51 if(Hero.x-x==0)
13540 {
13541 4 ndir=(Hero.y+8<y)?up:down;
13542 4 }
13543 else //turn to face Hero
13544 {
13545 double _MSVC2022_tmp1, _MSVC2022_tmp2;
13546 47 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
13547
13548
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 2 times.
47 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
13549 {
13550 2 ndir=down;
13551 2 }
13552
4/4
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 21 times.
45 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
13553 {
13554 21 ndir=right;
13555 21 }
13556
4/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 6 times.
24 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
13557 {
13558 6 ndir=up;
13559 6 }
13560 else
13561 {
13562 18 ndir=left;
13563 }
13564 }
13565
13566 51 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
13567
13568
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 50 times.
51 if(canmove(ndir,false))
13569 {
13570 50 dir=ndir;
13571 50 }
13572 51 }
13573 1850 }
13574
15/16
✓ Branch 0 taken 4697136 times.
✓ Branch 1 taken 19919 times.
✓ Branch 2 taken 77631 times.
✓ Branch 3 taken 4639424 times.
✓ Branch 4 taken 68668 times.
✓ Branch 5 taken 8963 times.
✓ Branch 6 taken 64419 times.
✓ Branch 7 taken 4249 times.
✓ Branch 8 taken 64032 times.
✓ Branch 9 taken 387 times.
✓ Branch 10 taken 59622 times.
✓ Branch 11 taken 4410 times.
✓ Branch 12 taken 59622 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 58678 times.
4717055 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
13575
3/3
✓ Branch 0 taken 6646 times.
✓ Branch 1 taken 51139 times.
✓ Branch 2 taken 893 times.
58678 switch(dmisc1)
13576 {
13577 case e1tCONSTANT: //Deathnut
13578 {
13579 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
13580
2/2
✓ Branch 0 taken 50065 times.
✓ Branch 1 taken 1074 times.
51139 if(clk5>64)
13581 {
13582 1074 clk5=0;
13583 1074 fired=false;
13584 1074 }
13585
13586 51139 clk5+=(zc_oldrand()&3);
13587
13588
4/4
✓ Branch 0 taken 31433 times.
✓ Branch 1 taken 19706 times.
✓ Branch 2 taken 10663 times.
✓ Branch 3 taken 20770 times.
51139 if((clk5>24)&&(clk5<52))
13589 {
13590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20770 times.
20770 if ( do_animation )tile+=20; //firing
13591
13592
4/4
✓ Branch 0 taken 11340 times.
✓ Branch 1 taken 9430 times.
✓ Branch 2 taken 10187 times.
✓ Branch 3 taken 1153 times.
20770 if(!fired&&(clk5>=38))
13593 {
13594
5/10
✓ Branch 0 taken 1153 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1153 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1153 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1153 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1153 times.
✗ Branch 9 not taken.
1153 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
13595 1153 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
13596 1153 sfx(wpnsfx(wpn),pan(int32_t(x)));
13597 1153 fired=true;
13598 1153 }
13599 20770 }
13600
13601 51139 break;
13602 }
13603
13604 case e1tFIREOCTO: //Fire Octo
13605 893 timer=zc_oldrand()%50+50;
13606 893 break;
13607
13608 default:
13609 6646 FireWeapon();
13610 6646 break;
13611 58678 }
13612
13613 /* Fire again if:
13614 * - clk2 about to run out
13615 * - not already double-firing (dmisc1 is 1)
13616 * - not carrying Hero
13617 * - one in 0xF chance
13618 */
13619
8/10
✓ Branch 0 taken 162576 times.
✓ Branch 1 taken 4556329 times.
✓ Branch 2 taken 1580 times.
✓ Branch 3 taken 160996 times.
✓ Branch 4 taken 1580 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1580 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 112 times.
✓ Branch 9 taken 1468 times.
4718905 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
13620 {
13621 #if 1
13622 112 newdir(rate, homing, grumble);
13623 #else
13624 dir^=2;
13625 #endif
13626 112 clk2=28;
13627 112 ++multishot;
13628 112 }
13629
13630
2/2
✓ Branch 0 taken 1253022 times.
✓ Branch 1 taken 3465883 times.
4718905 if(clk2==0)
13631 {
13632 3465883 multishot = 0;
13633 3465883 }
13634
13635
2/2
✓ Branch 0 taken 4655352 times.
✓ Branch 1 taken 63553 times.
4718905 if(timer) //Fire Octo
13636 {
13637 63553 clk2=15; //this keeps the octo in place until he's done firing
13638
13639
2/2
✓ Branch 0 taken 47985 times.
✓ Branch 1 taken 15568 times.
63553 if(!(timer%4))
13640 {
13641 15568 FireBreath(false);
13642 15568 }
13643
13644 63553 --timer;
13645 63553 }
13646
13647
2/2
✓ Branch 0 taken 4566948 times.
✓ Branch 1 taken 151957 times.
4718905 if(dmisc2==e2tTRIBBLE)
13648 151957 ++clk4;
13649
13650
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 4718905 times.
✓ Branch 2 taken 564 times.
✓ Branch 3 taken 4718341 times.
✓ Branch 4 taken 564 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 564 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 564 times.
4718905 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
13651 {
13652 564 int32_t kids = guys.Count();
13653 564 int32_t id2=dmisc3;
13654
13655
2/2
✓ Branch 0 taken 564 times.
✓ Branch 1 taken 564 times.
1128 for(int32_t i=0; i<dmisc4; i++)
13656 {
13657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 564 times.
564 if(addenemy(x,y,id2,-24))
13658 {
13659
1/2
✓ Branch 0 taken 564 times.
✗ Branch 1 not taken.
564 if(itemguy) // Hand down the carried item
13660 {
13661 guycarryingitem = guys.Count()-1;
13662 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13663 itemguy = false;
13664 }
13665
13666 564 ((enemy*)guys.spr(kids+i))->count_enemy = false;
13667 564 }
13668 564 }
13669
13670
1/2
✓ Branch 0 taken 564 times.
✗ Branch 1 not taken.
564 if(hashero)
13671 {
13672 Hero.setEaten(0);
13673 hashero=false;
13674 }
13675
13676 564 stop_bgsfx(index);
13677 564 return true;
13678 }
13679
13680 4718341 return enemy::animate(index);
13681 4829643 }
13682
13683 5036244 void eStalfos::draw(BITMAP *dest)
13684 {
13685 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc<=0) //Submerged
13686 {
13687 clk4--; //Kludge
13688 return;
13689 }*/
13690
13691 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc>1)
13692 {
13693 cs = dcset;
13694 }*/
13695 5036244 update_enemy_frame();
13696
13697
6/8
✓ Branch 0 taken 5036244 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5036244 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1941 times.
✓ Branch 5 taken 5034303 times.
✓ Branch 6 taken 1810 times.
✓ Branch 7 taken 131 times.
5036244 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
13698 {
13699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
131 if ( do_animation )tile+=20;
13700 131 }
13701
13702 5036244 enemy::draw(dest);
13703 5036244 }
13704
13705 881926 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
13706 {
13707 881926 int32_t tempy=yofs;
13708
13709 /*
13710 if (clk6 && dir>=left && !get_bit(quest_rules,qr_ENEMIESZAXIS)) {
13711 flip = 0;
13712 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
13713 (clk/(frate/4)):((clk>=(frate>>1))?1:0);
13714 shadowtile = wpnsbuf[spr_shadow].tile+f2;
13715 yofs+=(((int32_t)y+17)&0xF0)-y;
13716 yofs+=8;
13717 }
13718 */
13719
3/4
✓ Branch 0 taken 846362 times.
✓ Branch 1 taken 35564 times.
✓ Branch 2 taken 881926 times.
✗ Branch 3 not taken.
881926 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_bit(quest_rules,qr_ENEMIESZAXIS))
13720 {
13721 flip = 0;
13722 int32_t fdiv = frate/4;
13723 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13724
13725 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
13726 efrate:((clk>=(frate>>1))?1:0);
13727 shadowtile = wpnsbuf[spr_shadow].tile;
13728
13729 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13730 {
13731 shadowtile+=f2;
13732 }
13733 else
13734 {
13735 shadowtile+=f2?1:0;
13736 }
13737
13738 yofs+=shadowdistance;
13739 yofs+=8;
13740 }
13741
3/4
✓ Branch 0 taken 846362 times.
✓ Branch 1 taken 35564 times.
✓ Branch 2 taken 881926 times.
✗ Branch 3 not taken.
881926 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_bit(quest_rules,qr_POLVIRE_NO_SHADOW))
13742 {
13743 flip = 0;
13744 int32_t fdiv = frate/4;
13745 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13746
13747 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
13748 efrate:((clk>=(frate>>1))?1:0);
13749 shadowtile = wpnsbuf[spr_shadow].tile;
13750
13751 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13752 {
13753 shadowtile+=f2;
13754 }
13755 else
13756 {
13757 shadowtile+=f2?1:0;
13758 }
13759 }
13760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 881926 times.
881926 if(!shadow_overpit(this))
13761 881926 enemy::drawshadow(dest, translucent);
13762 881926 yofs=tempy;
13763 881926 }
13764
13765 64620 int32_t eStalfos::takehit(weapon *w)
13766 {
13767 64620 int32_t wpnId = w->id;
13768 64620 int32_t wpnDir = w->dir;
13769
13770
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 64620 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
64620 if(wpnId==wHammer && shield && (flags & guy_bkshield)
13771 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
13772 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
13773 {
13774 shield = false;
13775 flags &= ~(inv_left|inv_right|inv_back|inv_front);
13776
13777 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
13778 o_tile=s_tile;
13779 }
13780
13781 64620 int32_t ret = enemy::takehit(w);
13782
13783
4/4
✓ Branch 0 taken 6528 times.
✓ Branch 1 taken 58092 times.
✓ Branch 2 taken 5611 times.
✓ Branch 3 taken 917 times.
64620 if(sclk && dmisc2==e2tSPLITHIT)
13784 917 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
13785
13786 64620 return ret;
13787 }
13788
13789 303504 void eStalfos::charge_attack()
13790 {
13791
2/2
✓ Branch 0 taken 4245 times.
✓ Branch 1 taken 299259 times.
303504 if(slide())
13792 4245 return;
13793
13794
8/12
✓ Branch 0 taken 299259 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 299259 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 287387 times.
✓ Branch 5 taken 11872 times.
✓ Branch 6 taken 277070 times.
✓ Branch 7 taken 10317 times.
✓ Branch 8 taken 277070 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 277070 times.
299259 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
13795 22189 return;
13796
13797
2/2
✓ Branch 0 taken 11731 times.
✓ Branch 1 taken 265339 times.
277070 if(clk3<=0)
13798 {
13799 11731 fix_coords(true);
13800
13801
2/2
✓ Branch 0 taken 3993 times.
✓ Branch 1 taken 7738 times.
11731 if(!dashing)
13802 {
13803 7738 int32_t ldir = lined_up(7,false);
13804
13805
4/4
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 6930 times.
✓ Branch 2 taken 700 times.
✓ Branch 3 taken 108 times.
7738 if(ldir!=-1 && canmove(ldir,false))
13806 {
13807 700 dir=ldir;
13808 700 dashing=true;
13809 700 step=zslongToFix(dstep*100)+1;
13810 700 }
13811 7038 else newdir(4,0,0);
13812 7738 }
13813
13814
2/2
✓ Branch 0 taken 11252 times.
✓ Branch 1 taken 479 times.
11731 if(!canmove(dir,false))
13815 {
13816 479 step=zslongToFix(dstep*100);
13817 479 newdir();
13818 479 dashing=false;
13819 479 }
13820
13821 11731 zfix div = step;
13822
13823
1/2
✓ Branch 0 taken 11731 times.
✗ Branch 1 not taken.
11731 if(div == 0)
13824 div = 1;
13825
13826 11731 clk3=(int32_t)(16.0/div);
13827 11731 return;
13828 }
13829
13830 265339 move(step);
13831 265339 --clk3;
13832 303504 }
13833
13834 265274 void eStalfos::vire_hop()
13835 {
13836 //if ( sclk > 0 ) return; //Don't hop during knockback.
13837
13838 // if(dmisc9!=e9tPOLSVOICE)
13839 // {
13840 // //if( slide() /*sclk!=0*/ && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
13841 // if( sclk!=0 && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
13842 // return; //the enemy should split if it is sliding!
13843 // //else sclk=0; //might need this here, too. -Z
13844 // }
13845
2/2
✓ Branch 0 taken 108344 times.
✓ Branch 1 taken 156930 times.
265274 if(dmisc9!=e9tPOLSVOICE)
13846 {
13847
2/2
✓ Branch 0 taken 103703 times.
✓ Branch 1 taken 4641 times.
108344 if(sclk!=0)
13848 {
13849
2/2
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 3843 times.
4641 if (dmisc2==e2tSPLITHIT) return;
13850 //return;
13851 3843 }
13852 107546 }
13853 156930 else sclk=0;
13854
13855
8/12
✓ Branch 0 taken 264476 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 264476 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 258019 times.
✓ Branch 5 taken 6457 times.
✓ Branch 6 taken 252460 times.
✓ Branch 7 taken 5559 times.
✓ Branch 8 taken 252460 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 252460 times.
264476 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
13856 12016 return;
13857
13858 252460 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
13859 252460 int32_t jump_height = (dmisc9==e9tPOLSVOICE) ? 27 : 16;
13860
13861 252460 y=floor_y;
13862
13863
2/2
✓ Branch 0 taken 244077 times.
✓ Branch 1 taken 8383 times.
252460 if(clk3<=0)
13864 {
13865 8383 fix_coords();
13866
13867 //z=0;
13868 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
13869 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
13870
5/10
✓ Branch 0 taken 1681 times.
✓ Branch 1 taken 6702 times.
✓ Branch 2 taken 1488 times.
✓ Branch 3 taken 193 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1488 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8383 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & FLAG_OBEYS_GRAV)))) //Vires in old quests
13871 6895 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
13872
13873
2/2
✓ Branch 0 taken 1681 times.
✓ Branch 1 taken 6702 times.
8383 if(clk2<=0)
13874 {
13875 //z=0;
13876
6/6
✓ Branch 0 taken 6208 times.
✓ Branch 1 taken 494 times.
✓ Branch 2 taken 6101 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 4358 times.
✓ Branch 5 taken 1743 times.
6702 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
13877 {
13878
13879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4959 times.
4959 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
13880 /*if (dmisc9==e9tPOLSVOICE )
13881 {
13882 zprint2("polsvoice jump_width is: %d\n", jump_width);
13883 zprint2("polsvoice raw step is: %d\n", step);
13884 zprint2("polsvoice step.getInt() is: %d\n", step.getInt());
13885 zprint2("setting clk2 on polsvoice to: %d\n", clk2);
13886 }
13887 else
13888 {
13889 zprint2("vire jump_width is: %d\n", jump_width);
13890 zprint2("vire raw step is: %d\n", step);
13891 zprint2("vire step.getInt() is: %d\n", step.getInt());
13892 zprint2("setting clk2 on vire to: %d\n", clk2);
13893 }
13894 */
13895 4959 }
13896 6702 }
13897
13898
4/4
✓ Branch 0 taken 3345 times.
✓ Branch 1 taken 5038 times.
✓ Branch 2 taken 1501 times.
✓ Branch 3 taken 1844 times.
8383 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
13899 {
13900 1844 clk2=int32_t((16.0*jump_width)/step.getFloat());
13901 1844 }
13902
13903 8383 clk3=int32_t(16.0/step.getFloat());
13904 8383 }
13905
13906 252460 --clk3;
13907
13908
3/4
✓ Branch 0 taken 99764 times.
✓ Branch 1 taken 152696 times.
✓ Branch 2 taken 99764 times.
✗ Branch 3 not taken.
252460 if(dmisc9==e9tPOLSVOICE || clk2>0)
13909 252460 move(step);
13910
13911 252460 floor_y=y;
13912 252460 clk2--;
13913
13914 //if we're in the middle of a jump
13915
6/6
✓ Branch 0 taken 192206 times.
✓ Branch 1 taken 60254 times.
✓ Branch 2 taken 82283 times.
✓ Branch 3 taken 109923 times.
✓ Branch 4 taken 38735 times.
✓ Branch 5 taken 43548 times.
252460 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
13916 {
13917 148658 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
13918
13919
3/4
✓ Branch 0 taken 64043 times.
✓ Branch 1 taken 84615 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64043 times.
148658 if(get_bit(quest_rules,qr_ENEMIESZAXIS) && !(isSideViewGravity()))
13920 {
13921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64043 times.
64043 if (moveflags & FLAG_USE_FAKE_Z) fakez=h;
13922 64043 else z=h;
13923 64043 }
13924 else
13925 {
13926 //y+=fixtoi(fixsin(itofix((clk2+1)*128*step/(16*jump_width)))*jump_height);
13927 //y-=h;
13928 84615 y=floor_y-h;
13929 84615 shadowdistance=h;
13930 }
13931 148658 }
13932 else
13933 103802 shadowdistance = 0;
13934 265274 }
13935
13936 41 void eStalfos::eathero()
13937 {
13938
5/8
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 22 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 22 times.
41 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
13939 {
13940 22 hashero=true;
13941 22 y=floor_y;
13942 22 z=0;
13943
13944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(Hero.isSwimming())
13945 {
13946 Hero.setX(x);
13947 Hero.setY(y);
13948 }
13949 else
13950 {
13951 22 x=Hero.getX();
13952 22 y=Hero.getY();
13953 }
13954
13955 22 clk2=0;
13956 22 }
13957 41 }
13958
13959 424544 bool eStalfos::WeaponOut()
13960 {
13961
2/2
✓ Branch 0 taken 943782 times.
✓ Branch 1 taken 169462 times.
1113244 for(int32_t i=0; i<Ewpns.Count(); i++)
13962 {
13963
3/4
✓ Branch 0 taken 255082 times.
✓ Branch 1 taken 688700 times.
✓ Branch 2 taken 255082 times.
✗ Branch 3 not taken.
943782 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
13964 {
13965 255082 return true;
13966 }
13967
13968 /*if (bgsfx > 0 && guys.idCount(id) < 2) // count self
13969 stop_sfx(bgsfx);
13970 */
13971 688700 }
13972
13973 169462 return false;
13974 424544 }
13975
13976 106618 void eStalfos::KillWeapon()
13977 {
13978
2/2
✓ Branch 0 taken 106618 times.
✓ Branch 1 taken 137143 times.
243761 for(int32_t i=0; i<Ewpns.Count(); i++)
13979 {
13980
4/4
✓ Branch 0 taken 118579 times.
✓ Branch 1 taken 18564 times.
✓ Branch 2 taken 118337 times.
✓ Branch 3 taken 242 times.
137143 if(((weapon*)Ewpns.spr(i))->type==misc && Ewpns.spr(i)->id==ewBrang)
13981 {
13982 //only kill this Goriya's boomerang -DD
13983
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 115 times.
242 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
13984 {
13985 115 Ewpns.del(i);
13986 115 }
13987 242 }
13988 137143 }
13989
13990
4/4
✓ Branch 0 taken 7486 times.
✓ Branch 1 taken 99132 times.
✓ Branch 2 taken 3543 times.
✓ Branch 3 taken 3943 times.
106618 if(wpn==ewBrang && !Ewpns.idCount(ewBrang))
13991 {
13992 3543 stop_sfx(WAV_BRANG);
13993 3543 }
13994 106618 }
13995
13996 void eStalfos::break_shield()
13997 {
13998 if(!shield)
13999 return;
14000
14001 flags&=~(inv_front | inv_back | inv_left | inv_right);
14002 shield=false;
14003
14004 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
14005 o_tile=s_tile;
14006 }
14007
14008 6502 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14009 6502 {
14010
1/2
✓ Branch 0 taken 3251 times.
✗ Branch 1 not taken.
3251 dir=(zc_oldrand()&7)+8;
14011
1/2
✓ Branch 0 taken 3251 times.
✗ Branch 1 not taken.
3251 step=0;
14012 3251 movestatus=1;
14013
3/4
✓ Branch 0 taken 2431 times.
✓ Branch 1 taken 820 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2431 times.
3251 if (dmisc1 != 1 && dmisc19 > 0)
14014 {
14015 step = dmisc19/100.0;
14016 movestatus = 1;
14017 }
14018
1/2
✓ Branch 0 taken 3251 times.
✗ Branch 1 not taken.
3251 if (dmisc1 == 2) movestatus=2;
14019 3251 c=0;
14020 3251 SIZEflags = d->SIZEflags;
14021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3251 times.
3251 if ( !(SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) ) hxofs=2;
14022
1/2
✓ Branch 0 taken 3251 times.
✗ Branch 1 not taken.
3251 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
14023
14024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3251 times.
3251 if ( !(SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ) hxsz=12;
14025
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3251 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3251 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
14026
14027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3251 times.
3251 if ( !(SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) ) hyofs=4;
14028
1/2
✓ Branch 0 taken 3251 times.
✗ Branch 1 not taken.
3251 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
14029
14030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3251 times.
3251 if ( !(SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ) hysz=8;
14031
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3251 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3251 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hysz = d->hysz;
14032
14033
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3251 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3251 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
14034 //al_trace("->txsz:%i\n", d->txsz); Verified that this is setting the value. -Z
14035 // al_trace("Enemy txsz:%i\n", txsz);
14036
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3251 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3251 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
14037
14038
14039
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3251 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3251 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
14040
14041
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3251 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3251 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
14042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3251 times.
3251 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
14043 {
14044 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
14045 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
14046 }
14047
14048
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3251 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3251 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
14049 3251 clk4=0;
14050 //nets;
14051 3251 dummy_int[1]=0;
14052 3251 }
14053
14054 1052813 bool eKeese::animate(int32_t index)
14055 {
14056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1052813 times.
1052813 if(switch_hooked) return enemy::animate(index);
14057
2/4
✓ Branch 0 taken 1052813 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1052813 times.
1052813 if(fallclk||drownclk) return enemy::animate(index);
14058
2/2
✓ Branch 0 taken 40136 times.
✓ Branch 1 taken 1012677 times.
1052813 if(dying)
14059 40136 return Dead(index);
14060
14061
2/2
✓ Branch 0 taken 1007078 times.
✓ Branch 1 taken 5599 times.
1012677 if(clk==0)
14062 {
14063 5599 removearmos(x,y,ffcactivated);
14064 5599 }
14065
14066
2/2
✓ Branch 0 taken 323422 times.
✓ Branch 1 taken 689255 times.
1012677 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
14067 {
14068 323422 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
14069 323422 }
14070 else
14071 {
14072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 689255 times.
689255 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
14073 689255 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
14074 }
14075
14076
2/2
✓ Branch 0 taken 3672 times.
✓ Branch 1 taken 1009005 times.
1012677 if(dmisc2 == e2tKEESETRIB)
14077 {
14078
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3672 times.
✓ Branch 2 taken 3664 times.
✓ Branch 3 taken 8 times.
3672 if(++clk4==(dmisc20>0?dmisc20:256))
14079 {
14080
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 6 times.
8 if(!m_walkflag(x,y,0, dir))
14081 {
14082 6 int32_t kids = guys.Count();
14083 6 bool success = false;
14084 6 int32_t id2=dmisc3;
14085 6 success = 0 != addenemy((zfix)x,(zfix)y,id2,-24);
14086
14087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(success)
14088 {
14089
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(itemguy) // Hand down the carried item
14090 {
14091 guycarryingitem = guys.Count()-1;
14092 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
14093 itemguy = false;
14094 }
14095
14096 6 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
14097 6 }
14098
14099 6 stop_bgsfx(index);
14100 6 return true;
14101 }
14102 else
14103 {
14104 2 clk4=0;
14105 }
14106 2 }
14107 3666 }
14108 // Keese Tribbles stay on the ground, so there's no problem when they transform.
14109
3/4
✓ Branch 0 taken 392628 times.
✓ Branch 1 taken 616377 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 392628 times.
1009005 else if(get_bit(quest_rules,qr_ENEMIESZAXIS) && !(isSideViewGravity()))
14110 {
14111
1/2
✓ Branch 0 taken 392628 times.
✗ Branch 1 not taken.
392628 if (get_bit(quest_rules,qr_OLD_KEESE_Z_AXIS))
14112 {
14113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 392628 times.
392628 if (moveflags & FLAG_USE_FAKE_Z)
14114 {
14115 fakez=int32_t(step/zslongToFix(dstep*100));
14116 // Some variance in keese flight heights when away from Hero
14117 fakez+=int32_t(step*zc_max(zfix(0),(distance(x,y,HeroX(),HeroY())-128)/10));
14118
14119 }
14120 else
14121 {
14122 392628 z=int32_t(step/zslongToFix(dstep*100));
14123 // Some variance in keese flight heights when away from Hero
14124
2/2
✓ Branch 0 taken 317669 times.
✓ Branch 1 taken 74959 times.
392628 z+=int32_t(step*zc_max(zfix(0),(distance(x,y,HeroX(),HeroY())-128)/10));
14125 }
14126 392628 }
14127 else
14128 {
14129 if (moveflags & FLAG_USE_FAKE_Z)
14130 {
14131 fakez=int32_t(step/zslongToFix(dstep*100));
14132 // Some variance in keese flight heights when away from Hero
14133 fakez+=int32_t(step*zc_max(zfix(0),(distance(x,y,HeroX(),HeroY())-40)/4));
14134
14135 }
14136 else
14137 {
14138 z=int32_t(step/zslongToFix(dstep*100));
14139 // Some variance in keese flight heights when away from Hero
14140 z+=int32_t(step*zc_max(zfix(0),(distance(x,y,HeroX(),HeroY())-40)/4));
14141 }
14142 }
14143 392628 }
14144
14145 1012671 return enemy::animate(index);
14146 1052813 }
14147
14148 211848 void eKeese::drawshadow(BITMAP *dest, bool translucent)
14149 {
14150 211848 int32_t tempy=yofs;
14151 211848 flip = 0;
14152 211848 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
14153
14154
2/2
✓ Branch 0 taken 77446 times.
✓ Branch 1 taken 134402 times.
211848 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
14155
2/2
✓ Branch 0 taken 205925 times.
✓ Branch 1 taken 5923 times.
211848 if(!get_bit(quest_rules,qr_ENEMIESZAXIS))
14156 {
14157 5923 yofs+=int32_t(step/zslongToFix(dstep*10));
14158 5923 }
14159
14160
6/6
✓ Branch 0 taken 211607 times.
✓ Branch 1 taken 241 times.
✓ Branch 2 taken 205925 times.
✓ Branch 3 taken 5682 times.
✓ Branch 4 taken 199956 times.
✓ Branch 5 taken 5969 times.
211848 if(!shadow_overpit(this) && (!get_bit(quest_rules,qr_ENEMIESZAXIS) || step > 0))
14161 205638 enemy::drawshadow(dest, translucent);
14162 211848 yofs=tempy;
14163 211848 }
14164
14165 2475169 void eKeese::draw(BITMAP *dest)
14166 {
14167 2475169 update_enemy_frame();
14168 2475169 enemy::draw(dest);
14169 2475169 }
14170
14171 8059 void eWizzrobe::submerge(bool set)
14172 {
14173
1/2
✓ Branch 0 taken 8059 times.
✗ Branch 1 not taken.
8059 if(get_bit(quest_rules,qr_OLD_WIZZROBE_SUBMERGING))
14174 {
14175 8059 hxofs = set?1000:0;
14176 8059 return;
14177 }
14178 if(submerged == set) return;
14179 submerged = set;
14180 if(set)
14181 hxofs+=1000;
14182 else hxofs -= 1000;
14183 8059 }
14184 2348 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14185 2348 {
14186 1174 hxofs = 0;
14187 1174 submerged = false;
14188
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 694 times.
1174 switch(dmisc1)
14189 {
14190 case 0:
14191
1/2
✓ Branch 0 taken 694 times.
✗ Branch 1 not taken.
694 submerge(true);
14192 694 fading=fade_invisible;
14193 // Set clk to just before the 'reappear' threshold
14194
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 694 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 694 times.
✓ Branch 4 taken 603 times.
✓ Branch 5 taken 91 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 603 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 91 times.
694 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
14195 694 break;
14196
14197 default:
14198 480 dir=(loadside==right)?right:left;
14199 480 misc=-3;
14200 480 break;
14201 }
14202
14203 //netst+2880;
14204 1174 charging=false;
14205 1174 firing=false;
14206 1174 fclk=0;
14207
2/2
✓ Branch 0 taken 694 times.
✓ Branch 1 taken 480 times.
1174 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
14208 1174 SIZEflags = d->SIZEflags;
14209
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1174 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1174 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
14210 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
14211 // al_trace("Enemy txsz:%i\n", txsz);
14212
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1174 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1174 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
14213
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1174 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1174 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
14214
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1174 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1174 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hysz = d->hysz;
14215
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1174 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1174 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
14216
1/2
✓ Branch 0 taken 1174 times.
✗ Branch 1 not taken.
1174 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 )
14217 {
14218 hxofs = (submerged?hxofs:0)+d->hxofs;
14219 }
14220
1/2
✓ Branch 0 taken 1174 times.
✗ Branch 1 not taken.
1174 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
14221 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
14222
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1174 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1174 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
14223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1174 times.
1174 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
14224 {
14225 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
14226 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
14227 }
14228
14229
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1174 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1174 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
14230 1174 }
14231
14232 621727 bool eWizzrobe::animate(int32_t index)
14233 {
14234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 621727 times.
621727 if(switch_hooked) return enemy::animate(index);
14235
2/4
✓ Branch 0 taken 621727 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 621727 times.
621727 if(fallclk||drownclk) return enemy::animate(index);
14236
2/2
✓ Branch 0 taken 13158 times.
✓ Branch 1 taken 608569 times.
621727 if(dying)
14237 {
14238 13158 return Dead(index);
14239 }
14240
14241
2/2
✓ Branch 0 taken 589784 times.
✓ Branch 1 taken 18785 times.
608569 if(clk==0)
14242 {
14243 18785 removearmos(x,y,ffcactivated);
14244 18785 }
14245
14246
2/2
✓ Branch 0 taken 310365 times.
✓ Branch 1 taken 298204 times.
608569 if(dmisc1) // Floating
14247 {
14248 310365 wizzrobe_attack();
14249 310365 }
14250 else // Teleporting
14251 {
14252
3/6
✓ Branch 0 taken 293715 times.
✓ Branch 1 taken 4489 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 293715 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
298204 if(watch || (!get_bit(quest_rules, qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
14253 {
14254 4489 fading=0;
14255 4489 submerge(false);
14256 4489 solid_update(false);
14257 4489 }
14258
8/8
✓ Branch 0 taken 283926 times.
✓ Branch 1 taken 1725 times.
✓ Branch 2 taken 1523 times.
✓ Branch 3 taken 1465 times.
✓ Branch 4 taken 1445 times.
✓ Branch 5 taken 1257 times.
✓ Branch 6 taken 1223 times.
✓ Branch 7 taken 1151 times.
293715 else switch(clk)
14259 {
14260 case 0:
14261
2/2
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 1298 times.
1725 if(!dmisc2)
14262 {
14263 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
14264 // but should not appear on dungeon walls.
14265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1298 times.
1298 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
14266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1298 times.
1298 else if (editorflags&ENEMY_FLAG5)
14267 {
14268 //2.10 Windrobe
14269 //randomise location and face Hero
14270 int32_t t=0;
14271 bool placed=false;
14272
14273 while(!placed && t<160)
14274 {
14275 if(isdungeon())
14276 {
14277 x=((zc_oldrand()%12)+2)*16;
14278 y=((zc_oldrand()%7)+2)*16;
14279 }
14280 else
14281 {
14282 x=((zc_oldrand()%14)+1)*16;
14283 y=((zc_oldrand()%9)+1)*16;
14284 }
14285
14286 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
14287 {
14288 placed=true;
14289 }
14290
14291 ++t;
14292 }
14293
14294 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
14295 {
14296 if(y<Hero.getY())
14297 {
14298 dir=down;
14299 }
14300 else
14301 {
14302 dir=up;
14303 }
14304 }
14305 else
14306 {
14307 if(x<Hero.getX())
14308 {
14309 dir=right;
14310 }
14311 else
14312 {
14313 dir=left;
14314 }
14315 }
14316
14317 if(!placed) // can't place him, he's gone
14318 return true;
14319
14320
14321 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
14322 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
14323 }
14324 1298 else place_on_axis(true, dmisc4!=0);
14325 1298 }
14326 else
14327 {
14328 427 int32_t t=0;
14329 427 bool placed=false;
14330
14331
4/4
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 556 times.
✓ Branch 2 taken 556 times.
✓ Branch 3 taken 427 times.
983 while(!placed && t<160)
14332 {
14333
2/2
✓ Branch 0 taken 539 times.
✓ Branch 1 taken 17 times.
556 if(isdungeon())
14334 {
14335 539 x=((zc_oldrand()%12)+2)*16;
14336 539 y=((zc_oldrand()%7)+2)*16;
14337 539 }
14338 else
14339 {
14340 17 x=((zc_oldrand()%14)+1)*16;
14341 17 y=((zc_oldrand()%9)+1)*16;
14342 }
14343
14344
6/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 495 times.
✓ Branch 2 taken 342 times.
✓ Branch 3 taken 153 times.
✓ Branch 4 taken 129 times.
✓ Branch 5 taken 427 times.
1051 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
14345 {
14346 427 placed=true;
14347 427 }
14348
14349 556 ++t;
14350 }
14351
14352
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 283 times.
427 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
14353 {
14354
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 56 times.
144 if(y<Hero.getY())
14355 {
14356 88 dir=down;
14357 88 }
14358 else
14359 {
14360 56 dir=up;
14361 }
14362 144 }
14363 else
14364 {
14365
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 143 times.
283 if(x<Hero.getX())
14366 {
14367 140 dir=right;
14368 140 }
14369 else
14370 {
14371 143 dir=left;
14372 }
14373 }
14374
14375
1/2
✓ Branch 0 taken 427 times.
✗ Branch 1 not taken.
427 if(!placed) // can't place him, he's gone
14376 return true;
14377 }
14378
14379 1725 fading=fade_flicker;
14380 1725 submerge(false);
14381 1725 solid_update(false);
14382 1725 break;
14383
14384 case 64:
14385 1523 fading=0;
14386 1523 charging=true;
14387 1523 break;
14388
14389 case 73:
14390 1465 charging=false;
14391 1465 firing=40;
14392 1465 break;
14393
14394 case 83:
14395 1445 wizzrobe_attack_for_real();
14396 1445 break;
14397
14398 case 119:
14399 1257 firing=false;
14400 1257 charging=true;
14401 1257 break;
14402
14403 case 128:
14404 1223 fading=fade_flicker;
14405 1223 charging=false;
14406 1223 break;
14407
14408 case 146:
14409 1151 fading=fade_invisible;
14410 1151 submerge(true);
14411 1151 solid_update(false);
14412
14413 [[fallthrough]];
14414 default:
14415
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 285077 times.
✓ Branch 2 taken 283348 times.
✓ Branch 3 taken 1729 times.
285077 if(clk>=(146+zc_max(0,dmisc5)))
14416 1729 clk=-1;
14417
14418 285077 break;
14419 }
14420 }
14421
14422 608569 return enemy::animate(index);
14423 621727 }
14424
14425 2411 void eWizzrobe::wizzrobe_attack_for_real()
14426 {
14427
1/2
✓ Branch 0 taken 2411 times.
✗ Branch 1 not taken.
2411 if(wpn==0) // Edited enemies
14428 return;
14429
14430
2/2
✓ Branch 0 taken 648 times.
✓ Branch 1 taken 1763 times.
2411 if(dmisc2 == 0) //normal weapon
14431 {
14432 1763 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
14433 1763 sfx(WAV_WAND,pan(int32_t(x)));
14434 1763 }
14435
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 399 times.
648 else if(dmisc2 == 1) // ring of fire
14436 {
14437 249 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
14438 249 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14439 249 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
14440 249 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14441 249 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
14442 249 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14443 249 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
14444 249 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14445 249 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
14446 249 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14447 249 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
14448 249 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14449 249 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
14450 249 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14451 249 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
14452 249 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14453 249 sfx(WAV_FIRE,pan(int32_t(x)));
14454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
249 if (get_bit(quest_rules, qr_8WAY_SHOT_SFX)) sfx(WAV_FIRE,pan(int32_t(x)));
14455 else
14456 {
14457
2/18
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 230 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
249 switch(wpn)
14458 {
14459 19 case ewFireball: sfx(40,pan(int32_t(x))); break;
14460
14461 case ewArrow: sfx(1,pan(int32_t(x))); break; //Ghost.zh has 0?
14462 case ewBrang: sfx(4,pan(int32_t(x))); break; //Ghost.zh has 0?
14463 case ewSword: sfx(20,pan(int32_t(x))); break; //Ghost.zh has 0?
14464 case ewRock: sfx(51,pan(int32_t(x))); break;
14465 case ewMagic: sfx(32,pan(int32_t(x))); break;
14466 case ewBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0?
14467 case ewSBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0?
14468 case ewLitBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0?
14469 case ewLitSBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0?
14470 case ewFireTrail: sfx(13,pan(int32_t(x))); break;
14471 230 case ewFlame: sfx(13,pan(int32_t(x))); break;
14472 case ewWind: sfx(32,pan(int32_t(x))); break;
14473 case ewFlame2: sfx(13,pan(int32_t(x))); break;
14474 case ewFlame2Trail: sfx(13,pan(int32_t(x))); break;
14475 case ewIce: sfx(44,pan(int32_t(x))); break;
14476 case ewFireball2: sfx(40,pan(int32_t(x))); break; //fireball (rising)
14477 default: sfx(WAV_FIRE,pan(int32_t(x))); break;
14478
14479 }
14480 }
14481 249 }
14482
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 14 times.
399 else if(dmisc2==2) // summons specific enemy
14483 {
14484 385 int32_t bc=0;
14485
14486
2/2
✓ Branch 0 taken 4183 times.
✓ Branch 1 taken 385 times.
4568 for(int32_t gc=0; gc<guys.Count(); gc++)
14487 {
14488
2/2
✓ Branch 0 taken 2242 times.
✓ Branch 1 taken 1941 times.
4183 if((((enemy*)guys.spr(gc))->id) == dmisc3)
14489 {
14490 1941 ++bc;
14491 1941 }
14492 4183 }
14493
14494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 385 times.
385 if(bc<=40)
14495 {
14496 385 int32_t kids = guys.Count();
14497 385 int32_t bats=(zc_oldrand()%3)+1;
14498
14499
2/2
✓ Branch 0 taken 784 times.
✓ Branch 1 taken 385 times.
1169 for(int32_t i=0; i<bats; i++)
14500 {
14501 // Summon bats (or anything)
14502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 784 times.
784 if(addchild(x,y,dmisc3,-10, this->script_UID))
14503 784 ((enemy*)guys.spr(kids+i))->count_enemy = false;
14504 784 }
14505
14506 385 sfx(WAV_FIRE,pan(int32_t(x)));
14507 385 }
14508 385 }
14509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 else if(dmisc2==3) //summon from layer
14510 {
14511
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(count_layer_enemies()==0)
14512 {
14513 return;
14514 }
14515
14516 14 int32_t kids = guys.Count();
14517
14518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(kids<200)
14519 {
14520 14 int32_t newguys=(zc_oldrand()%3)+1;
14521 14 bool summoned=false;
14522
14523
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 14 times.
39 for(int32_t i=0; i<newguys; i++)
14524 {
14525 25 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
14526 25 int32_t x2=0;
14527 25 int32_t y2=0;
14528
14529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 for(int32_t k=0; k<20; ++k)
14530 {
14531 27 x2=16*((zc_oldrand()%12)+2);
14532 27 y2=16*((zc_oldrand()%7)+2);
14533
14534
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 25 times.
54 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
14535 {
14536
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(addchild(x2,y2,get_bit(quest_rules,qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
14537 {
14538 25 ((enemy*)guys.spr(kids+i))->count_enemy = false;
14539
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25 if (get_bit(quest_rules,qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & FLAG_USE_FAKE_Z))
14540 {
14541 ((enemy*)guys.spr(kids+i))->fakez = 64;
14542 ((enemy*)guys.spr(kids+i))->z = 0;
14543 }
14544 25 }
14545
14546 25 summoned=true;
14547 25 break;
14548 }
14549 2 }
14550 25 }
14551
14552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(summoned)
14553 {
14554 14 sfx(get_bit(quest_rules,qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
14555 14 }
14556 14 }
14557 14 }
14558 2411 }
14559
14560
14561 310365 void eWizzrobe::wizzrobe_attack()
14562 {
14563
9/12
✓ Branch 0 taken 302865 times.
✓ Branch 1 taken 7500 times.
✓ Branch 2 taken 302865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300160 times.
✓ Branch 5 taken 2705 times.
✓ Branch 6 taken 298009 times.
✓ Branch 7 taken 2151 times.
✓ Branch 8 taken 298009 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 298009 times.
310365 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
14564 12356 return;
14565
14566
3/8
✓ Branch 0 taken 286600 times.
✓ Branch 1 taken 11409 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 286600 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
298009 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
14567 {
14568 11409 fix_coords();
14569
14570
5/5
✓ Branch 0 taken 1222 times.
✓ Branch 1 taken 403 times.
✓ Branch 2 taken 5880 times.
✓ Branch 3 taken 2431 times.
✓ Branch 4 taken 1473 times.
11409 switch(misc)
14571 {
14572 case 1: //walking
14573
2/2
✓ Branch 0 taken 1791 times.
✓ Branch 1 taken 640 times.
2431 if(!m_walkflag(x,y,spw_door, dir))
14574 640 misc=0;
14575 else
14576 {
14577 1791 clk3=16;
14578
14579
2/2
✓ Branch 0 taken 1630 times.
✓ Branch 1 taken 161 times.
1791 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
14580 {
14581 161 wizzrobe_newdir(0);
14582 161 }
14583 }
14584
14585 2431 break;
14586
14587 case 2: //phasing
14588 {
14589 1473 int32_t jx=x;
14590 1473 int32_t jy=y;
14591 1473 int32_t jdir=-1;
14592
14593
5/5
✓ Branch 0 taken 754 times.
✓ Branch 1 taken 186 times.
✓ Branch 2 taken 172 times.
✓ Branch 3 taken 176 times.
✓ Branch 4 taken 185 times.
1473 switch(zc_oldrand()&7)
14594 {
14595 case 0:
14596 186 jx-=32;
14597 186 jy-=32;
14598 186 jdir=15;
14599 186 break;
14600
14601 case 1:
14602 172 jx+=32;
14603 172 jy-=32;
14604 172 jdir=9;
14605 172 break;
14606
14607 case 2:
14608 176 jx+=32;
14609 176 jy+=32;
14610 176 jdir=11;
14611 176 break;
14612
14613 case 3:
14614 185 jx-=32;
14615 185 jy+=32;
14616 185 jdir=13;
14617 185 break;
14618 }
14619
14620
10/10
✓ Branch 0 taken 719 times.
✓ Branch 1 taken 754 times.
✓ Branch 2 taken 632 times.
✓ Branch 3 taken 87 times.
✓ Branch 4 taken 588 times.
✓ Branch 5 taken 44 times.
✓ Branch 6 taken 512 times.
✓ Branch 7 taken 76 times.
✓ Branch 8 taken 418 times.
✓ Branch 9 taken 94 times.
1473 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
14621 {
14622 418 misc=3;
14623 418 clk3=32;
14624 418 dir=jdir;
14625 418 break;
14626 }
14627 1055 }
14628 [[fallthrough]];
14629 case 3:
14630 1458 dir&=3;
14631 1458 misc=0;
14632 [[fallthrough]];
14633 case 0:
14634 7338 wizzrobe_newdir(64);
14635 [[fallthrough]];
14636 default:
14637
2/2
✓ Branch 0 taken 7820 times.
✓ Branch 1 taken 740 times.
8560 if(!canmove(dir,(zfix)1,spw_door,false))
14638 {
14639
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 29 times.
740 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
14640 {
14641 711 misc=1;
14642 711 clk3=16;
14643 711 }
14644 else
14645 {
14646 29 wizzrobe_newdir(64);
14647 29 misc=0;
14648 29 clk3=32;
14649 }
14650 740 }
14651 else
14652 {
14653 7820 clk3=32;
14654 }
14655
14656 8560 break;
14657 }
14658
14659
2/2
✓ Branch 0 taken 10323 times.
✓ Branch 1 taken 1086 times.
11409 if(misc<0)
14660 1086 ++misc;
14661 11409 }
14662
14663 298009 --clk3;
14664
14665
3/3
✓ Branch 0 taken 52595 times.
✓ Branch 1 taken 221268 times.
✓ Branch 2 taken 24146 times.
298009 switch(misc)
14666 {
14667 case 1:
14668 case 3:
14669 52595 step=1;
14670 52595 break;
14671
14672 case 2:
14673 24146 step=0;
14674 24146 break;
14675
14676 default:
14677 221268 step=0.5;
14678 221268 break;
14679
14680 }
14681
14682 298009 move(step);
14683
14684 // if(d->misc1 && misc<=0 && clk3==28)
14685
5/6
✓ Branch 0 taken 298009 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 221268 times.
✓ Branch 3 taken 76741 times.
✓ Branch 4 taken 213630 times.
✓ Branch 5 taken 7638 times.
298009 if(dmisc1 && misc<=0 && clk3==28)
14686 {
14687
2/2
✓ Branch 0 taken 6494 times.
✓ Branch 1 taken 1144 times.
7638 if(dmisc2 != 1)
14688 {
14689
2/2
✓ Branch 0 taken 5777 times.
✓ Branch 1 taken 717 times.
6494 if(lined_up(8,false) == dir)
14690 {
14691 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
14692 // sfx(WAV_WAND,pan(int32_t(x)));
14693 717 wizzrobe_attack_for_real();
14694 717 fclk=30;
14695 717 }
14696 6494 }
14697 else
14698 {
14699
2/2
✓ Branch 0 taken 895 times.
✓ Branch 1 taken 249 times.
1144 if((zc_oldrand()%500)>=400)
14700 {
14701 249 wizzrobe_attack_for_real();
14702 249 fclk=30;
14703 249 }
14704 }
14705 7638 }
14706
14707
4/4
✓ Branch 0 taken 197044 times.
✓ Branch 1 taken 100965 times.
✓ Branch 2 taken 1503 times.
✓ Branch 3 taken 195541 times.
298009 if(misc==0 && (zc_oldrand()&127)==0)
14708 1503 misc=2;
14709
14710
4/4
✓ Branch 0 taken 25649 times.
✓ Branch 1 taken 272360 times.
✓ Branch 2 taken 24363 times.
✓ Branch 3 taken 1286 times.
298009 if(misc==2 && clk3==4)
14711 1286 fix_coords();
14712
14713
2/4
✓ Branch 0 taken 298009 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 298009 times.
298009 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
14714 {
14715
2/2
✓ Branch 0 taken 270455 times.
✓ Branch 1 taken 27554 times.
298009 if(fclk>0)
14716 {
14717 27554 --fclk;
14718 27554 }
14719 298009 }
14720
14721 310365 }
14722
14723 7528 void eWizzrobe::wizzrobe_newdir(int32_t homing)
14724 {
14725 // Wizzrobes shouldn't move to the edge of the screen;
14726 // if they're already there, they should move toward the center
14727
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 7524 times.
7528 if(x<32)
14728 4 dir=right;
14729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7524 times.
7524 else if(x>=224)
14730 dir=left;
14731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7524 times.
7524 else if(y<32)
14732 dir=down;
14733
1/2
✓ Branch 0 taken 7524 times.
✗ Branch 1 not taken.
7524 else if(y>=144)
14734 dir=up;
14735 else
14736 7524 newdir(4,homing,spw_wizzrobe);
14737 7528 }
14738
14739 621691 void eWizzrobe::draw(BITMAP *dest)
14740 {
14741 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
14742
12/14
✓ Branch 0 taken 315106 times.
✓ Branch 1 taken 306585 times.
✓ Branch 2 taken 274244 times.
✓ Branch 3 taken 40862 times.
✓ Branch 4 taken 27321 times.
✓ Branch 5 taken 287785 times.
✓ Branch 6 taken 27019 times.
✓ Branch 7 taken 302 times.
✓ Branch 8 taken 26262 times.
✓ Branch 9 taken 757 times.
✓ Branch 10 taken 26262 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 26262 times.
✗ Branch 13 not taken.
621691 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
14743 26262 return;
14744
14745 595429 int32_t tempint=dummy_int[1];
14746 595429 bool tempbool1=dummy_bool[1];
14747 595429 bool tempbool2=dummy_bool[2];
14748 595429 dummy_int[1]=fclk;
14749 595429 dummy_bool[1]=charging;
14750 595429 dummy_bool[2]=firing;
14751 595429 update_enemy_frame();
14752 595429 dummy_int[1]=tempint;
14753 595429 dummy_bool[1]=tempbool1;
14754 595429 dummy_bool[2]=tempbool2;
14755 595429 enemy::draw(dest);
14756 621691 }
14757
14758 /*********************************/
14759 /********** Bosses ***********/
14760 /*********************************/
14761
14762 160 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14763 160 {
14764 80 fading=fade_flash_die;
14765 //nets+5120;
14766
6/8
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 22 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 19 times.
✓ Branch 7 taken 3 times.
80 if(dir==down&&y>=128)
14767 {
14768 3 dir=up;
14769 3 }
14770
14771
5/8
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 25 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 25 times.
✗ Branch 7 not taken.
80 if(dir==right&&x>=208)
14772 {
14773 dir=left;
14774 }
14775 80 SIZEflags = d->SIZEflags;
14776
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
14777 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
14778 // al_trace("Enemy txsz:%i\n", txsz);
14779
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
14780
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
14781
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
14782
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
14783
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
14784
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
14785 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
14786
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
14787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
14788 {
14789 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
14790 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
14791 }
14792
14793
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
14794 80 }
14795
14796 66476 bool eDodongo::animate(int32_t index)
14797 {
14798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66476 times.
66476 if(switch_hooked) return enemy::animate(index);
14799
2/2
✓ Branch 0 taken 2736 times.
✓ Branch 1 taken 63740 times.
66476 if(dying)
14800 {
14801 2736 return Dead(index);
14802 }
14803
14804
2/2
✓ Branch 0 taken 63458 times.
✓ Branch 1 taken 282 times.
63740 if(clk==0)
14805 {
14806 282 removearmos(x,y,ffcactivated);
14807 282 }
14808
14809
2/2
✓ Branch 0 taken 6816 times.
✓ Branch 1 taken 56924 times.
63740 if(clk2) // ate a bomb
14810 {
14811
2/2
✓ Branch 0 taken 6745 times.
✓ Branch 1 taken 71 times.
6816 if(--clk2==0)
14812 71 hp-=misc; // store bomb's power in misc
14813 6816 }
14814 else
14815 56924 constant_walk(rate,homing,spw_clipright);
14816
14817 63740 hxsz = (dir<=down) ? 16 : 32;
14818 // hysz = (dir>=left) ? 16 : 32;
14819
14820 63740 return enemy::animate(index);
14821 66476 }
14822
14823 66466 void eDodongo::draw(BITMAP *dest)
14824 {
14825 66466 tile=o_tile;
14826
14827
2/2
✓ Branch 0 taken 1365 times.
✓ Branch 1 taken 65101 times.
66466 if(clk<0)
14828 {
14829 1365 enemy::drawzcboss(dest);
14830 1365 return;
14831 }
14832
14833 65101 update_enemy_frame();
14834 65101 enemy::drawzcboss(dest);
14835
14836
2/2
✓ Branch 0 taken 27132 times.
✓ Branch 1 taken 37969 times.
65101 if(dummy_int[1]!=0) //additional tiles
14837 {
14838 37969 tile+=dummy_int[1]; //second tile is previous tile
14839 37969 xofs-=16; //new xofs change
14840 37969 enemy::drawzcboss(dest);
14841 37969 xofs+=16;
14842 37969 }
14843
14844 66466 }
14845
14846 4489 int32_t eDodongo::takehit(weapon *w)
14847 {
14848 4489 int32_t wpnId = w->id;
14849 4489 int32_t power = w->power;
14850 4489 int32_t wpnx = w->x;
14851 4489 int32_t wpny = w->y;
14852
14853
5/12
✓ Branch 0 taken 4489 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4489 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1380 times.
✓ Branch 5 taken 3109 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1380 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
4489 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
14854 3109 return 0;
14855
14856
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 510 times.
✓ Branch 2 taken 791 times.
✓ Branch 3 taken 10 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 69 times.
1380 switch(wpnId)
14857 {
14858 case wPhantom:
14859 return 0;
14860
14861 case wFire:
14862 case wBait:
14863 case wWhistle:
14864 case wWind:
14865 case wSSparkle:
14866 case wFSparkle:
14867 return 0;
14868
14869 case wLitBomb:
14870 case wLitSBomb:
14871
6/6
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 333 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 310 times.
✓ Branch 4 taken 439 times.
✓ Branch 5 taken 71 times.
510 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
14872 439 return 0;
14873
14874 71 clk2=96;
14875 71 misc=power;
14876
14877
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 3 times.
71 if(wpnId==wLitSBomb)
14878 3 item_set=isSBOMB100;
14879
14880 71 return 1;
14881
14882 case wBomb:
14883 case wSBomb:
14884
6/6
✓ Branch 0 taken 357 times.
✓ Branch 1 taken 434 times.
✓ Branch 2 taken 257 times.
✓ Branch 3 taken 534 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 485 times.
791 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
14885 306 return 0;
14886
14887 485 stunclk=160;
14888 485 misc=wpnId; // store wpnId
14889 485 return 1;
14890
14891 case wSword:
14892
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 47 times.
69 if(stunclk)
14893 {
14894 47 sfx(WAV_EHIT,pan(int32_t(x)));
14895 47 hp=0;
14896 47 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
14897 47 fading=0; // don't flash
14898 47 return 1;
14899 }
14900
14901 [[fallthrough]];
14902 default:
14903 32 sfx(WAV_CHINK,pan(int32_t(x)));
14904 32 }
14905
14906 32 return 1;
14907 4489 }
14908
14909 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14910 {
14911 fading=fade_flash_die;
14912 //nets+5180;
14913 previous_dir=-1;
14914 if(dir==down&&y>=128)
14915 {
14916 dir=up;
14917 }
14918
14919 if(dir==right&&x>=208)
14920 {
14921 dir=left;
14922 }
14923 SIZEflags = d->SIZEflags;
14924 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
14925 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
14926 // al_trace("Enemy txsz:%i\n", txsz);
14927 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
14928 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
14929 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
14930 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
14931 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
14932 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
14933 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
14934 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
14935 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
14936 {
14937 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
14938 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
14939 }
14940
14941 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
14942 }
14943
14944 bool eDodongo2::animate(int32_t index)
14945 {
14946 if(switch_hooked) return enemy::animate(index);
14947 if(dying)
14948 {
14949 return Dead(index);
14950 }
14951
14952 if(clk==0)
14953 {
14954 removearmos(x,y,ffcactivated);
14955 }
14956
14957 if(clk2) // ate a bomb
14958 {
14959 if(--clk2==0)
14960 hp-=misc; // store bomb's power in misc
14961 }
14962 else
14963 constant_walk(rate,homing,spw_clipbottomright);
14964
14965 hxsz = (dir<=down) ? 16 : 32;
14966 hysz = (dir>=left) ? 16 : 32;
14967 hxofs=(dir>=left)?-8:0;
14968 hyofs=(dir<left)?-8:0;
14969
14970 return enemy::animate(index);
14971 }
14972
14973 void eDodongo2::draw(BITMAP *dest)
14974 {
14975 if(clk<0)
14976 {
14977 enemy::drawzcboss(dest);
14978 return;
14979 }
14980
14981 int32_t tempx=xofs;
14982 int32_t tempy=yofs;
14983 update_enemy_frame();
14984 enemy::drawzcboss(dest);
14985 tile+=dummy_int[1]; //second tile change
14986 xofs+=dummy_int[2]; //new xofs change
14987 yofs+=dummy_int[3]; //new yofs change
14988 enemy::drawzcboss(dest);
14989 xofs=tempx;
14990 yofs=tempy;
14991 }
14992
14993 int32_t eDodongo2::takehit(weapon *w)
14994 {
14995 int32_t wpnId = w->id;
14996 int32_t power = w->power;
14997 int32_t wpnx = w->x;
14998 int32_t wpny = w->y;
14999
15000 if(dying || clk<0 || clk2>0 || superman)
15001 return 0;
15002
15003 switch(wpnId)
15004 {
15005 case wPhantom:
15006 return 0;
15007
15008 case wFire:
15009 case wBait:
15010 case wWhistle:
15011 case wWind:
15012 case wSSparkle:
15013 case wFSparkle:
15014 return 0;
15015
15016 case wLitBomb:
15017 case wLitSBomb:
15018 switch(dir)
15019 {
15020 case up:
15021 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
15022 return 0;
15023
15024 break;
15025
15026 case down:
15027 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
15028 return 0;
15029
15030 break;
15031
15032 case left:
15033 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
15034 return 0;
15035
15036 break;
15037
15038 case right:
15039 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
15040 return 0;
15041
15042 break;
15043 }
15044
15045 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
15046 // return 0;
15047 clk2=96;
15048 misc=power;
15049
15050 if(wpnId==wLitSBomb)
15051 item_set=isSBOMB100;
15052
15053 return 1;
15054
15055 case wBomb:
15056 case wSBomb:
15057 switch(dir)
15058 {
15059 case up:
15060 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
15061 return 0;
15062
15063 break;
15064
15065 case down:
15066 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
15067 return 0;
15068
15069 break;
15070
15071 case left:
15072 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
15073 return 0;
15074
15075 break;
15076
15077 case right:
15078 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
15079 return 0;
15080
15081 break;
15082 }
15083
15084 stunclk=160;
15085 misc=wpnId; // store wpnId
15086 return 1;
15087
15088 case wSword:
15089 if(stunclk)
15090 {
15091 sfx(WAV_EHIT,pan(int32_t(x)));
15092 hp=0;
15093 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
15094 fading=0; // don't flash
15095 return 1;
15096 }
15097
15098 [[fallthrough]];
15099 default:
15100 sfx(WAV_CHINK,pan(int32_t(x)));
15101 }
15102
15103 return 1;
15104 }
15105
15106 72 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
15107 72 {
15108 //these are here to bypass compiler warnings about unused arguments
15109
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if ( !(editorflags & ENEMY_FLAG5) )
15110 {
15111
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 x = dmisc1 ? 64 : 176;
15112
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 y = 64;
15113 36 }
15114 else { x = X; y = Y; }
15115
15116 //nets+5940;
15117
3/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 23 times.
36 if(get_bit(quest_rules,qr_NEWENEMYTILES))
15118 {
15119 13 }
15120 else
15121 {
15122
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 16 times.
23 if(dmisc1)
15123 {
15124 7 flip=1;
15125 7 }
15126 }
15127
15128
3/6
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
36 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
15129 36 clk3=32;
15130 36 clk2=0;
15131 36 clk4=clk;
15132 36 dir=left;
15133 36 SIZEflags = d->SIZEflags;
15134
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
36 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15135 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15136 // al_trace("Enemy txsz:%i\n", txsz);
15137
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
36 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
15138
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
36 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
15139
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
36 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
15140
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
36 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
15141
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
15142
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
15143 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15144
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
36 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
15145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15146 {
15147 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
15148 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
15149 }
15150
15151
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
36 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
15152 36 }
15153
15154 21293 bool eAquamentus::animate(int32_t index)
15155 {
15156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21293 times.
21293 if(switch_hooked) return enemy::animate(index);
15157
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 20681 times.
21293 if(dying)
15158 612 return Dead(index);
15159
15160 // fbx=x+((id==eRAQUAM)?4:-4);
15161
2/2
✓ Branch 0 taken 20587 times.
✓ Branch 1 taken 94 times.
20681 if(clk==0)
15162 {
15163 94 removearmos(x,y,ffcactivated);
15164 94 }
15165
15166 20681 fbx=x;
15167
15168 /*
15169 if (get_bit(quest_rules,qr_NEWENEMYTILES)&&id==eLAQUAM)
15170 {
15171 fbx+=16;
15172 }
15173 */
15174
2/2
✓ Branch 0 taken 20547 times.
✓ Branch 1 taken 134 times.
20681 if(--clk3==0)
15175 {
15176 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
15177 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
15178 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
15179 134 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
15180 134 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
15181 134 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
15182 134 sfx(wpnsfx(wpn),pan(int32_t(x)));
15183 134 }
15184
15185
4/4
✓ Branch 0 taken 6252 times.
✓ Branch 1 taken 14429 times.
✓ Branch 2 taken 103 times.
✓ Branch 3 taken 6149 times.
20681 if(clk3<-80 && !(zc_oldrand()&63))
15186 {
15187 103 clk3=32;
15188 103 }
15189
15190
2/2
✓ Branch 0 taken 20351 times.
✓ Branch 1 taken 330 times.
20681 if(!((clk4+1)&63))
15191 {
15192 330 int32_t d2=(zc_oldrand()%3)+1;
15193
15194
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 230 times.
330 if(d2>=left)
15195 {
15196 230 dir=d2;
15197 230 }
15198
15199
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 217 times.
330 if(dmisc1)
15200 {
15201
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 11 times.
113 if(x<=40)
15202 {
15203 11 dir=right;
15204 11 }
15205
15206
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(x>=104)
15207 {
15208 dir=left;
15209 }
15210 113 }
15211 else
15212 {
15213
2/2
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 6 times.
217 if(x<=136)
15214 {
15215 6 dir=right;
15216 6 }
15217
15218
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 10 times.
217 if(x>=200)
15219 {
15220 10 dir=left;
15221 10 }
15222 }
15223 330 }
15224
15225
4/4
✓ Branch 0 taken 20177 times.
✓ Branch 1 taken 504 times.
✓ Branch 2 taken 17640 times.
✓ Branch 3 taken 2537 times.
20681 if(clk4>=-1 && !((clk4+1)&7))
15226 {
15227
2/2
✓ Branch 0 taken 1376 times.
✓ Branch 1 taken 1161 times.
2537 if(dir==left)
15228 {
15229 1376 x-=1;
15230 1376 }
15231 else
15232 {
15233 1161 x+=1;
15234 }
15235 2537 }
15236
15237 20681 clk4=(clk4+1)%256;
15238
15239 20681 return enemy::animate(index);
15240 21293 }
15241
15242 21319 void eAquamentus::draw(BITMAP *dest)
15243 {
15244
2/2
✓ Branch 0 taken 5865 times.
✓ Branch 1 taken 15454 times.
21319 if(get_bit(quest_rules,qr_NEWENEMYTILES))
15245 {
15246 5865 xofs=(dmisc1?-16:0);
15247
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5865 times.
✓ Branch 2 taken 2457 times.
✓ Branch 3 taken 3408 times.
5865 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
15248
15249
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 5649 times.
5865 if(dying)
15250 {
15251 216 xofs=0;
15252 216 enemy::draw(dest);
15253 216 }
15254 else
15255 {
15256 5649 drawblock(dest,15);
15257 }
15258 5865 }
15259 else
15260 {
15261 15454 int32_t xblockofs=((dmisc1)?-16:16);
15262 15454 xofs=0;
15263
15264
4/4
✓ Branch 0 taken 15109 times.
✓ Branch 1 taken 345 times.
✓ Branch 2 taken 396 times.
✓ Branch 3 taken 14713 times.
15454 if(clk<0 || dying)
15265 {
15266 741 enemy::draw(dest);
15267 741 return;
15268 }
15269
1/2
✓ Branch 0 taken 14713 times.
✗ Branch 1 not taken.
14713 if ( do_animation )
15270 {
15271 // face (0=firing, 2=resting)
15272 14713 tile=o_tile+((clk3>0)?0:2);
15273 14713 enemy::draw(dest);
15274 // tail (
15275 14713 tile=o_tile+((clk&16)?1:3);
15276 14713 xofs=xblockofs;
15277 14713 enemy::draw(dest);
15278 // body
15279 14713 yofs+=16;
15280 14713 xofs=0;
15281 14713 tile=o_tile+((clk&16)?20:22);
15282 14713 enemy::draw(dest);
15283 14713 xofs=xblockofs;
15284 14713 tile=o_tile+((clk&16)?21:23);
15285 14713 enemy::draw(dest);
15286 14713 yofs-=16;
15287 14713 }
15288 else enemy::draw(dest);
15289 }
15290 21319 }
15291
15292 5812 bool eAquamentus::hit(weapon *w)
15293 {
15294
3/6
✓ Branch 0 taken 5812 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5812 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5812 times.
5812 if(!(w->scriptcoldet&1) || w->fallclk || w->drownclk) return false;
15295
15296
2/2
✓ Branch 0 taken 2621 times.
✓ Branch 1 taken 3191 times.
5812 switch(w->id)
15297 {
15298 case wBeam:
15299 case wRefBeam:
15300 case wMagic:
15301 2621 hysz=32;
15302 2621 }
15303
15304
4/4
✓ Branch 0 taken 5702 times.
✓ Branch 1 taken 110 times.
✓ Branch 2 taken 3910 times.
✓ Branch 3 taken 1792 times.
5812 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
15305 5812 hysz=16;
15306 5812 return ret;
15307
15308 5812 }
15309
15310 48 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
15311 48 {
15312
15313
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if ( !(editorflags & ENEMY_FLAG5) )
15314 {
15315
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 x = 128;
15316
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 y = 48;
15317 24 }
15318 else { x = X; y = Y; }
15319
15320 24 Clk=Clk;
15321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(flags & guy_fadeflicker)
15322 {
15323 clk=0;
15324 superman = 1;
15325 fading=fade_flicker;
15326 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
15327 }
15328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 else if(flags & guy_fadeinstant)
15329 {
15330 24 clk=0;
15331 24 }
15332 24 hxofs=-16;
15333 24 hxsz=48;
15334 24 clk4=0;
15335
3/6
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
24 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
15336
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 dir=zc_oldrand()%3+1;
15337 24 SIZEflags = d->SIZEflags;
15338
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
24 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15339 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15340 // al_trace("Enemy txsz:%i\n", txsz);
15341
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
24 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
15342
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
24 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = hxsz;
15343
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
24 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = hysz;
15344
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
24 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
15345
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
15346
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
15347 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15348
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
24 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
15349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15350 {
15351 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
15352 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
15353 }
15354
15355
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
24 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
15356
15357 //nets+5340;
15358 24 }
15359
15360 28583 bool eGohma::animate(int32_t index)
15361 {
15362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28583 times.
28583 if(switch_hooked) return enemy::animate(index);
15363
2/2
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 28187 times.
28583 if(dying)
15364 396 return Dead(index);
15365
15366
1/2
✓ Branch 0 taken 28187 times.
✗ Branch 1 not taken.
28187 if(fading)
15367 {
15368 if(++clk4 > 60)
15369 {
15370 clk4=0;
15371 superman=0;
15372 fading=0;
15373 clk=0;
15374
15375 }
15376 else return enemy::animate(index);
15377 }
15378
15379
2/2
✓ Branch 0 taken 28065 times.
✓ Branch 1 taken 122 times.
28187 if(clk==0)
15380 {
15381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 122 times.
122 if (ffcactivated) removearmosffc(ffcactivated-1);
15382 else
15383 {
15384
1/2
✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
122 removearmos(zc_max(x-16, zfix(0)),y);
15385 122 did_armos = false;
15386 122 removearmos(x,y);
15387 122 did_armos = false;
15388
1/2
✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
122 removearmos(zc_min(x+16, zfix(255)),y);
15389 }
15390 122 }
15391
15392
1/2
✓ Branch 0 taken 28187 times.
✗ Branch 1 not taken.
28187 if(clk<0) return enemy::animate(index);
15393
15394 // Movement clk must be separate from animation clk because of the Clock item
15395
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28187 times.
28187 if(!watch)
15396 28187 clk4++;
15397
15398
2/2
✓ Branch 0 taken 27756 times.
✓ Branch 1 taken 431 times.
28187 if((clk4&63)==0)
15399 {
15400
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 208 times.
431 if(clk4&64)
15401 223 dir^=1;
15402 else
15403 208 dir=zc_oldrand()%3+1;
15404 431 }
15405
15406
2/2
✓ Branch 0 taken 27734 times.
✓ Branch 1 taken 453 times.
28187 if((clk&63)==3)
15407 {
15408
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 150 times.
453 switch(dmisc1)
15409 {
15410 case 1:
15411 150 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
15412 150 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
15413 150 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
15414 150 sfx(wpnsfx(wpn),pan(int32_t(x)));
15415 150 break;
15416
15417 default:
15418
2/4
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 303 times.
303 if(dmisc1 != 1 && dmisc1 != 2)
15419 {
15420 303 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
15421 303 sfx(wpnsfx(wpn),pan(int32_t(x)));
15422 303 sfx(wpnsfx(wpn),pan(int32_t(x)));
15423 303 }
15424
15425 303 break;
15426 }
15427 453 }
15428
15429
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 28187 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
28187 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
15430 {
15431 if(!(clk3%8))
15432 {
15433 FireBreath(true);
15434 }
15435 }
15436
15437
2/2
✓ Branch 0 taken 14088 times.
✓ Branch 1 taken 14099 times.
28187 if(clk4&1)
15438 14099 move((zfix)1);
15439
15440
2/2
✓ Branch 0 taken 28121 times.
✓ Branch 1 taken 66 times.
28187 if(++clk3>=400)
15441 66 clk3=0;
15442
15443 28187 return enemy::animate(index);
15444 28583 }
15445
15446 28581 void eGohma::draw(BITMAP *dest)
15447 {
15448 28581 tile=o_tile;
15449
15450
3/4
✓ Branch 0 taken 28581 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 396 times.
✓ Branch 3 taken 28185 times.
28581 if(clk<0 || dying)
15451 {
15452 396 enemy::drawzcboss(dest);
15453 396 return;
15454 }
15455
15456
2/2
✓ Branch 0 taken 20608 times.
✓ Branch 1 taken 7577 times.
28185 if(get_bit(quest_rules,qr_NEWENEMYTILES))
15457 {
15458 ///if ( do_animation )
15459 //Yuck. Gohma can just not have this capability right now.
15460 // left side
15461 20608 xofs=-16;
15462 20608 flip=0;
15463 // if(clk&16) tile=180;
15464 // else { tile=182; flip=1; }
15465 20608 tile+=(3*((clk&48)>>4));
15466 20608 enemy::drawzcboss(dest);
15467
15468 // right side
15469 20608 xofs=16;
15470 // tile=(180+182)-tile;
15471 20608 tile=o_tile;
15472 20608 tile+=(3*((clk&48)>>4))+2;
15473 20608 enemy::drawzcboss(dest);
15474
15475 // body
15476 20608 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
15477 20608 tile=o_tile;
15478
15479 // tile+=(3*((clk&24)>>3))+2;
15480
2/2
✓ Branch 0 taken 1023 times.
✓ Branch 1 taken 19585 times.
20608 if(clk3<16)
15481 1023 tile+=7;
15482
2/2
✓ Branch 0 taken 5666 times.
✓ Branch 1 taken 13919 times.
19585 else if(clk3<116)
15483 5666 tile+=10;
15484
2/2
✓ Branch 0 taken 787 times.
✓ Branch 1 taken 13132 times.
13919 else if(clk3<132)
15485 787 tile+=7;
15486 else
15487 13132 tile+=((clk3-132)&24)?4:1;
15488
15489 20608 enemy::drawzcboss(dest);
15490
15491 20608 }
15492 else
15493 {
15494 // left side
15495 7577 xofs=-16;
15496 7577 flip=0;
15497
15498
2/2
✓ Branch 0 taken 3750 times.
✓ Branch 1 taken 3827 times.
7577 if(!(clk&16))
15499 {
15500 3827 tile+=2;
15501 3827 flip=1;
15502 3827 }
15503
15504 7577 enemy::draw(dest);
15505
15506 // right side
15507 7577 tile=o_tile;
15508 7577 xofs=16;
15509
15510
2/2
✓ Branch 0 taken 3827 times.
✓ Branch 1 taken 3750 times.
7577 if((clk&16)) tile+=2;
15511
15512 // tile=(180+182)-tile;
15513 7577 enemy::draw(dest);
15514
15515 // body
15516 7577 tile=o_tile;
15517 7577 xofs=0;
15518
15519
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 7161 times.
7577 if(clk3<16)
15520 416 tile+=4;
15521
2/2
✓ Branch 0 taken 2279 times.
✓ Branch 1 taken 4882 times.
7161 else if(clk3<116)
15522 2279 tile+=5;
15523
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 4585 times.
4882 else if(clk3<132)
15524 297 tile+=4;
15525 4585 else tile+=((clk3-132)&8)?3:1;
15526
15527 7577 enemy::draw(dest);
15528
15529 }
15530 28581 }
15531
15532 173 int32_t eGohma::takehit(weapon *w)
15533 {
15534 173 int32_t wpnId = w->id;
15535 173 int32_t power = w->power;
15536 173 int32_t wpnx = w->x;
15537 173 int32_t wpnDir = w->dir;
15538 173 int32_t def = defenditemclassNew(wpnId, &power, w);
15539
15540
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 72 times.
173 if(def < 0)
15541 {
15542
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 54 times.
✓ Branch 5 taken 18 times.
✓ Branch 6 taken 54 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 47 times.
✓ Branch 9 taken 7 times.
72 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
15543 {
15544 25 sfx(WAV_CHINK,pan(int32_t(x)));
15545 25 return 1;
15546 }
15547 47 }
15548
15549 148 return enemy::takehit(w);
15550 173 }
15551
15552 310 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
15553 310 {
15554 155 count_enemy=(id==(id&0xFFF));
15555 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
15556 155 SIZEflags = d->SIZEflags;
15557
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
155 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15558 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15559 // al_trace("Enemy txsz:%i\n", txsz);
15560
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
155 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
15561
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
155 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
15562
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
155 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
15563
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
155 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
15564
1/2
✓ Branch 0 taken 155 times.
✗ Branch 1 not taken.
155 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
15565
1/2
✓ Branch 0 taken 155 times.
✗ Branch 1 not taken.
155 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
15566 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15567
1/4
✓ Branch 0 taken 155 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
155 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
15568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155 times.
155 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15569 {
15570 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
15571 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
15572 }
15573
15574
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
155 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
15575 155 }
15576
15577 54657 bool eLilDig::animate(int32_t index)
15578 {
15579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54657 times.
54657 if(switch_hooked) return enemy::animate(index);
15580
2/2
✓ Branch 0 taken 2250 times.
✓ Branch 1 taken 52407 times.
54657 if(dying)
15581 2250 return Dead(index);
15582
15583
2/2
✓ Branch 0 taken 2686 times.
✓ Branch 1 taken 49721 times.
52407 if(clk==0)
15584 {
15585 2686 removearmos(x,y,ffcactivated);
15586 2686 }
15587
15588
2/2
✓ Branch 0 taken 33873 times.
✓ Branch 1 taken 18534 times.
52407 if(misc<=128)
15589 {
15590
2/2
✓ Branch 0 taken 559 times.
✓ Branch 1 taken 17975 times.
18534 if(!(++misc&31))
15591 559 step+=0.25;
15592 18534 }
15593
15594 52407 variable_walk_8(rate,homing,hrate,spw_floater);
15595 52407 return enemy::animate(index);
15596 54657 }
15597
15598 54534 void eLilDig::draw(BITMAP *dest)
15599 {
15600 54534 tile = o_tile;
15601 // tile = 160;
15602 54534 int32_t fdiv = frate/4;
15603
1/2
✓ Branch 0 taken 54534 times.
✗ Branch 1 not taken.
54534 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
15604
2/2
✓ Branch 0 taken 37096 times.
✓ Branch 1 taken 17438 times.
54534 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
15605 54534 efrate:((clk>=(frate>>1))?1:0);
15606
15607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54534 times.
54534 if ( do_animation )
15608 {
15609
2/2
✓ Branch 0 taken 37096 times.
✓ Branch 1 taken 17438 times.
54534 if(get_bit(quest_rules,qr_NEWENEMYTILES))
15610 {
15611
9/9
✓ Branch 0 taken 5025 times.
✓ Branch 1 taken 4289 times.
✓ Branch 2 taken 3978 times.
✓ Branch 3 taken 4325 times.
✓ Branch 4 taken 3984 times.
✓ Branch 5 taken 3675 times.
✓ Branch 6 taken 3105 times.
✓ Branch 7 taken 4063 times.
✓ Branch 8 taken 4652 times.
37096 switch(dir-8) //directions get screwed up after 8. *shrug*
15612 {
15613 case up: //u
15614 5025 flip=0;
15615 5025 break;
15616
15617 case l_up: //d
15618 4289 flip=0;
15619 4289 tile+=4;
15620 4289 break;
15621
15622 case l_down: //l
15623 3978 flip=0;
15624 3978 tile+=8;
15625 3978 break;
15626
15627 case left: //r
15628 4325 flip=0;
15629 4325 tile+=12;
15630 4325 break;
15631
15632 case r_down: //ul
15633 3984 flip=0;
15634 3984 tile+=20;
15635 3984 break;
15636
15637 case down: //ur
15638 3675 flip=0;
15639 3675 tile+=24;
15640 3675 break;
15641
15642 case r_up: //dl
15643 3105 flip=0;
15644 3105 tile+=28;
15645 3105 break;
15646
15647 case right: //dr
15648 4063 flip=0;
15649 4063 tile+=32;
15650 4063 break;
15651 }
15652
15653 37096 tile+=f2;
15654 37096 }
15655 else
15656 {
15657 17438 tile+=(clk>=6)?1:0;
15658 }
15659 54534 }
15660
15661 54534 enemy::draw(dest);
15662 54534 }
15663
15664 70 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
15665 70 {
15666 35 superman=1;
15667
15668 35 SIZEflags = d->SIZEflags;
15669
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15670 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15671 // al_trace("Enemy txsz:%i\n", txsz);
15672
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
15673
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
35 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
15674 35 else hxsz=32;
15675
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
35 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
15676 35 else hysz=32;
15677
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
35 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
15678 35 else hzsz=16; // hard to jump.
15679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
15680 35 else hxofs=-8;
15681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
15682 35 else hyofs=-8;
15683 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15684
1/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
35 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
15685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15686 {
15687 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
15688 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
15689 }
15690
15691
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
35 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
15692
15693
15694 35 }
15695
15696 13626 bool eBigDig::animate(int32_t index)
15697 {
15698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13626 times.
13626 if(switch_hooked) return enemy::animate(index);
15699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13626 times.
13626 if(dying)
15700 return Dead(index);
15701
15702
2/2
✓ Branch 0 taken 11816 times.
✓ Branch 1 taken 1810 times.
13626 if(clk==0)
15703 {
15704 1810 removearmos(x,y,ffcactivated);
15705 1810 }
15706
15707
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13562 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 32 times.
13626 switch(misc)
15708 {
15709 case 0:
15710 13562 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
15711 13562 break;
15712
15713 case 1:
15714 32 ++misc;
15715 32 break;
15716
15717 case 2:
15718
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 32 times.
134 for(int32_t i=0; i<dmisc5; i++)
15719 {
15720 102 addenemy(x,y,dmisc1+0x1000,-15);
15721 102 }
15722
15723
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 32 times.
39 for(int32_t i=0; i<dmisc6; i++)
15724 {
15725 7 addenemy(x,y,dmisc2+0x1000,-15);
15726 7 }
15727
15728
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 32 times.
39 for(int32_t i=0; i<dmisc7; i++)
15729 {
15730 7 addenemy(x,y,dmisc3+0x1000,-15);
15731 7 }
15732
15733
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 32 times.
39 for(int32_t i=0; i<dmisc8; i++)
15734 {
15735 7 addenemy(x,y,dmisc4+0x1000,-15);
15736 7 }
15737
15738
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(itemguy) // Hand down the carried item
15739 {
15740 guycarryingitem = guys.Count()-1;
15741 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
15742 itemguy = false;
15743 }
15744
15745 32 stop_bgsfx(index);
15746
15747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
15748
15749 32 return true;
15750 }
15751
15752 13594 return enemy::animate(index);
15753 13626 }
15754
15755 13621 void eBigDig::draw(BITMAP *dest)
15756 {
15757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13621 times.
13621 if(anim!=aDIG)
15758 {
15759 update_enemy_frame();
15760 xofs-=8;
15761 yofs-=8;
15762 drawblock(dest,15);
15763 xofs+=8;
15764 yofs+=8;
15765 return;
15766 }
15767
15768 13621 tile = o_tile;
15769 13621 int32_t fdiv = frate/4;
15770
1/2
✓ Branch 0 taken 13621 times.
✗ Branch 1 not taken.
13621 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
15771
15772
2/2
✓ Branch 0 taken 8935 times.
✓ Branch 1 taken 4686 times.
13621 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
15773 13621 efrate:((clk>=(frate>>1))?1:0);
15774
15775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13621 times.
13621 if ( do_animation )
15776 {
15777
2/2
✓ Branch 0 taken 8935 times.
✓ Branch 1 taken 4686 times.
13621 if(get_bit(quest_rules,qr_NEWENEMYTILES))
15778 {
15779
9/9
✓ Branch 0 taken 983 times.
✓ Branch 1 taken 1044 times.
✓ Branch 2 taken 1264 times.
✓ Branch 3 taken 923 times.
✓ Branch 4 taken 1186 times.
✓ Branch 5 taken 1016 times.
✓ Branch 6 taken 940 times.
✓ Branch 7 taken 1180 times.
✓ Branch 8 taken 399 times.
8935 switch(dir-8) //directions get screwed up after 8. *shrug*
15780 {
15781 case up: //u
15782 983 flip=0;
15783 983 break;
15784
15785 case l_up: //d
15786 1044 flip=0;
15787 1044 tile+=8;
15788 1044 break;
15789
15790 case l_down: //l
15791 1264 flip=0;
15792 1264 tile+=40;
15793 1264 break;
15794
15795 case left: //r
15796 923 flip=0;
15797 923 tile+=48;
15798 923 break;
15799
15800 case r_down: //ul
15801 1186 flip=0;
15802 1186 tile+=80;
15803 1186 break;
15804
15805 case down: //ur
15806 1016 flip=0;
15807 1016 tile+=88;
15808
15809 1016 break;
15810
15811 case r_up: //dl
15812 940 flip=0;
15813 940 tile+=120;
15814 940 break;
15815
15816 case right: //dr
15817 1180 flip=0;
15818 1180 tile+=128;
15819 1180 break;
15820 }
15821
15822 8935 tile+=(f2*2);
15823 8935 }
15824 else
15825 {
15826 4686 tile+=(f2)?0:2;
15827 4686 flip=(clk&1)?1:0;
15828 }
15829 13621 }
15830
15831 13621 xofs-=8;
15832 13621 yofs-=8;
15833 13621 drawblock(dest,15);
15834 13621 xofs+=8;
15835 13621 yofs+=8;
15836 13621 }
15837
15838 252 int32_t eBigDig::takehit(weapon *w)
15839 {
15840 252 int32_t wpnId = w->id;
15841
15842
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 220 times.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
252 if(wpnId==wWhistle && misc==0)
15843 32 misc=1;
15844
15845 252 return 0;
15846 }
15847
15848 /*
15849 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
15850 {
15851 hxofs=hyofs=8;
15852 hzsz=16; //can't be jumped.
15853 clk2=70;
15854 misc=-1;
15855 mainguy=!getmapflag();
15856 }
15857
15858 bool eGanon::animate(int32_t index)
15859 {
15860 if(switch_hooked) return enemy::animate(index);
15861 if(dying)
15862
15863 return Dead(index);
15864
15865 if(clk==0)
15866 {
15867 removearmos(x,y,ffcactivated);
15868 }
15869
15870 switch(misc)
15871 {
15872 case -1:
15873 misc=0;
15874
15875 case 0:
15876 if(++clk2>72 && !(zc_oldrand()&3))
15877 {
15878 addEwpn(x,y,z,wpn,3,wdp,dir,getUID());
15879 sfx(wpnsfx(wpn),pan(int32_t(x)));
15880 clk2=0;
15881 }
15882
15883 Stunclk=0;
15884 constant_walk(rate,homing,spw_none);
15885 break;
15886
15887 case 1:
15888 case 2:
15889 if(--Stunclk<=0)
15890 {
15891 int32_t r=zc_oldrand();
15892
15893 if(r&1)
15894 {
15895 y=96;
15896
15897 if(r&2)
15898 x=160;
15899 else
15900 x=48;
15901
15902 if(tooclose(x,y,48))
15903 x=208-x;
15904 }
15905
15906 //if ( editorflags & ENEMY_FLAG15 && current_item_id(itype_amulet,false) >= 2 ) //visible to Amulet 2
15907 //{
15908 // loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
15909 // }
15910 // else
15911 // {
15912 loadpalset(csBOSS,pSprite(d->bosspal));
15913 // }
15914 misc=0;
15915 }
15916
15917 break;
15918
15919 case 3:
15920 {
15921 if(hclk>0)
15922 break;
15923
15924 misc=4;
15925 clk=0;
15926 hxofs=1000;
15927 loadpalset(9,pSprite(spPILE));
15928 music_stop();
15929 stop_sfx(WAV_ROAR);
15930
15931 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
15932
15933 sfx(WAV_GANON);
15934 //Ganon's dustpile; fall in sideview. -Z
15935 item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
15936 dustpile->linked_parent = eeGANON;
15937 setmapflag();
15938 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
15939 break;
15940 }
15941
15942 case 4:
15943 if(clk>=80)
15944 {
15945 misc=5;
15946
15947 if(getmapflag())
15948 {
15949 game->lvlitems[dlevel]|=liBOSS;
15950 //play_DmapMusic();
15951 playLevelMusic();
15952 return true;
15953 }
15954
15955 sfx(WAV_CLEARED);
15956 items.add(new item(x+8,y+8,(zfix)0,iBigTri,ipBIGTRI,0));
15957 setmapflag();
15958 }
15959
15960 break;
15961 }
15962
15963 //if ( editorflags & ENEMY_FLAG15 ) //visible to Amulet 2
15964 //{
15965 //if ( current_item_id(itype_amulet,false) >= 2 )
15966 //{
15967 /// loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
15968 //}
15969 //}
15970
15971
15972 return enemy::animate(index);
15973 }
15974
15975
15976 int32_t eGanon::takehit(weapon *w)
15977 {
15978 //these are here to bypass compiler warnings about unused arguments
15979 int32_t wpnId = w->id;
15980 int32_t power = w->power;
15981 int32_t enemyHitWeapon = w->parentitem;
15982
15983 switch(misc)
15984 {
15985 case 0:
15986 {
15987 //if we're not using the editor defences, and Ganon isn't hit by a sword, return.
15988 if(wpnId!=wSword && !(editorflags & ENEMY_FLAG14))
15989 return 0;
15990
15991 //if we are not using the new defences, just reduce his HP
15992 if (!(editorflags & ENEMY_FLAG14))
15993 {
15994 hp-=power;
15995 if(hp>0)
15996 {
15997 misc=1;
15998 Stunclk=64;
15999 }
16000 else
16001 {
16002 loadpalset(csBOSS,pSprite(spBROWN));
16003 misc=2;
16004 Stunclk=284;
16005 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
16006 }
16007
16008 sfx(WAV_EHIT,pan(int32_t(x)));
16009
16010 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
16011
16012 return 1;
16013 }
16014 //otherwise, resolve his defence.
16015 else
16016 {
16017 int32_t def = enemy::takehit(w); //This works, but it instantly kills him if it does enough damage.
16018 if(hp>0)
16019 {
16020 misc=1;
16021 Stunclk=64;
16022 }
16023 else
16024 {
16025 loadpalset(csBOSS,pSprite(spBROWN));
16026 misc=2;
16027 Stunclk=284;
16028 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
16029 }
16030
16031 sfx(WAV_EHIT,pan(int32_t(x)));
16032
16033 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
16034
16035
16036 return 1;
16037 }
16038 }
16039 case 2:
16040 {
16041 if
16042 (
16043 ( dmisc14 > 0 && !enemyHitWeapon == dmisc14 ) //special weapon needed to kill ganon specified in editor
16044 || //or nothing specified, use silver arrows+
16045 ( dmisc14 <= 0 && (wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4))
16046 )
16047 return 0;
16048 {
16049 misc=3;
16050 hclk=81;
16051 loadpalset(9,pSprite(spBROWN));
16052 return 1;
16053 }
16054
16055 }
16056 }
16057
16058 return 0;
16059 }
16060
16061 void eGanon::draw(BITMAP *dest)
16062 {
16063 switch(misc)
16064 {
16065 case 0:
16066 if((clk&3)==3)
16067 tile=(zc_oldrand()%5)*2+o_tile;
16068
16069 if(db!=999)
16070 break;
16071
16072 case 2:
16073 if(Stunclk<64 && (Stunclk&1) )
16074 {
16075 if
16076 (
16077 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
16078 ||
16079 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
16080 )
16081 {
16082 goto ganon_draw; //draw his weapons if we can see him
16083 }
16084 break;
16085 }
16086
16087 case -1:
16088 tile=o_tile;
16089
16090 //fall through
16091 case 1:
16092 case 3:
16093 ganon_draw:
16094 drawblock(dest,15);
16095 break;
16096
16097 case 4:
16098 draw_guts(dest);
16099 draw_flash(dest);
16100 break;
16101 }
16102
16103 if ( editorflags & ENEMY_FLAG1 ) //visible to Amulet 2
16104 {
16105 if
16106 (
16107 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
16108 ||
16109 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
16110 )
16111 {
16112 draw_guts(dest); //makes his shots visible, but not him
16113 draw_flash(dest);
16114 }
16115 }
16116 }
16117
16118 void eGanon::draw_guts(BITMAP *dest)
16119 {
16120 int32_t c = zc_min(clk>>3,8);
16121 tile = clk<24 ? 74 : 75;
16122 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
16123 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
16124 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
16125 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
16126 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
16127 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
16128 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
16129 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
16130 }
16131
16132 void eGanon::draw_flash(BITMAP *dest)
16133 {
16134
16135 int32_t c = clk-(clk>>2);
16136 cs = (frame&3)+6;
16137 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
16138 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
16139 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
16140 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
16141 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
16142 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
16143 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
16144 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
16145 }
16146 */
16147
16148 8 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
16149 8 {
16150 4 hxofs=hyofs=8;
16151
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (editorflags & ENEMY_FLAG3)
16152 {
16153 hxofs = 4;
16154 hyofs = 4;
16155 hxsz = 24;
16156 hysz = 24;
16157 SIZEflags|=guyflagOVERRIDE_HIT_WIDTH;
16158 SIZEflags|=guyflagOVERRIDE_HIT_HEIGHT;
16159 }
16160 4 hzsz=16; //can't be jumped.
16161 4 clk2=70;
16162 4 misc=-1;
16163
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 mainguy=(!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN));
16164 4 }
16165
16166 8471 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
16167 {
16168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8471 times.
8471 if(dying)
16169
16170 return Dead(index);
16171
16172
2/2
✓ Branch 0 taken 8438 times.
✓ Branch 1 taken 33 times.
8471 if(clk==0)
16173 {
16174 33 removearmos(x,y,ffcactivated);
16175 33 }
16176
16177
6/7
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6304 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 328 times.
✓ Branch 5 taken 320 times.
✓ Branch 6 taken 2 times.
8471 switch(misc)
16178 {
16179 case -1:
16180 4 misc=0;
16181 [[fallthrough]];
16182 case 0:
16183
4/4
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 5969 times.
✓ Branch 2 taken 253 times.
✓ Branch 3 taken 86 times.
6308 if(++clk2>72 && !(zc_oldrand()&3))
16184 {
16185 86 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16186 86 sfx(wpnsfx(wpn),pan(int32_t(x)));
16187 86 clk2=0;
16188 86 }
16189
16190 6308 Stunclk=0;
16191 6308 constant_walk(rate,homing,spw_none);
16192 6308 break;
16193
16194 case 1:
16195 case 2:
16196
2/2
✓ Branch 0 taken 1493 times.
✓ Branch 1 taken 20 times.
1513 if(--Stunclk<=0)
16197 {
16198 20 int32_t r=zc_oldrand();
16199
16200
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 9 times.
20 if(r&1)
16201 {
16202 9 y=96;
16203
16204
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7 times.
9 if(r&2)
16205 2 x=160;
16206 else
16207 7 x=48;
16208
16209
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
9 if(tooclose(x,y,48))
16210 2 x=208-x;
16211 9 }
16212
16213 20 loadpalset(csBOSS,pSprite(d->bosspal));
16214 20 misc=0;
16215 20 }
16216
16217 1513 break;
16218
16219 case 3:
16220 {
16221
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 4 times.
328 if(hclk>0)
16222 324 break;
16223
16224 4 misc=4;
16225 4 clk=0;
16226 4 hxofs=1000;
16227 4 loadpalset(9,pSprite(spPILE));
16228 4 music_stop();
16229 4 stop_sfx(WAV_ROAR);
16230
16231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
16232
16233 4 sfx(WAV_GANON);
16234 //Ganon's dustpile; fall in sideview. -Z
16235 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
16236 //dustpile->miscellaneous[31] = eeGANON;
16237
6/12
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
4 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
16238 4 item *dustpile = NULL;
16239 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
16240 4 dustpile = (item *)items.spr(items.Count() - 1);
16241 4 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
16242 //setmapflag(); //Could be why the Triforce doesn't drop. Disabling this now. -Z ( 6th March, 2019 )
16243 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
16244 4 break;
16245 }
16246
16247 case 4:
16248
2/2
✓ Branch 0 taken 316 times.
✓ Branch 1 taken 4 times.
320 if(clk>=80)
16249 {
16250 4 misc=5;
16251
16252 //game->lvlitems[dlevel]|=liBOSS;
16253
16254 4 sfx(WAV_CLEARED);
16255 //Add the big TF over the ashes!
16256
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 for(word q = 0; q < items.Count(); q++)
16257 {
16258 8 item *ashes = (item*)items.spr(q);
16259
3/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
8 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
16260 {
16261 //Z_scripterrlog("Found correct dustpile!\n");
16262
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
16263 4 item *bigtriforce = NULL;
16264 4 bigtriforce = (item *)items.spr(items.Count() - 1);
16265 4 bigtriforce->linked_parent = eeGANON;
16266 4 }
16267 8 }
16268 //setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
16269 //game->lvlitems[dlevel]|=liBOSS; // if we had more rule bits, we could mark him dead so that he does not respawn. -Z
16270 4 }
16271
16272 320 break;
16273 2 case 5: return true;
16274 }
16275
16276 8469 return enemy::animate(index);
16277 8471 }
16278
16279
16280 484 int32_t eGanon::takehit(weapon *w)
16281 {
16282 //these are here to bypass compiler warnings about unused arguments
16283 484 int32_t wpnId = w->id;
16284 484 int32_t power = w->power;
16285 484 int32_t enemyHitWeapon = w->parentitem;
16286
16287
3/3
✓ Branch 0 taken 411 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 49 times.
484 switch(misc)
16288 {
16289 case 0:
16290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(wpnId!=wSword)
16291 return 0;
16292
16293 24 hp-=power;
16294
16295
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 4 times.
24 if(hp>0)
16296 {
16297 20 misc=1;
16298 20 Stunclk=64;
16299 20 }
16300 else
16301 {
16302 4 loadpalset(csBOSS,pSprite(spBROWN));
16303 4 misc=2;
16304 4 Stunclk=284;
16305 4 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
16306 }
16307
16308 24 sfx(WAV_EHIT,pan(int32_t(x)));
16309
16310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
16311
16312 24 return 1;
16313
16314 case 2:
16315
4/6
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
49 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
16316 45 return 0;
16317
16318 4 misc=3;
16319 4 hclk=81;
16320 4 loadpalset(9,pSprite(spBROWN));
16321 4 return 1;
16322 }
16323
16324 411 return 0;
16325 484 }
16326
16327 9247 void eGanon::draw(BITMAP *dest)
16328 {
16329
6/6
✓ Branch 0 taken 1608 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 233 times.
✓ Branch 3 taken 780 times.
✓ Branch 4 taken 6304 times.
✓ Branch 5 taken 320 times.
9247 switch(misc)
16330 {
16331 case 0:
16332
2/2
✓ Branch 0 taken 4728 times.
✓ Branch 1 taken 1576 times.
6304 if((clk&3)==3)
16333 1576 tile=(zc_oldrand()%5)*2+o_tile;
16334
16335
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6304 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6304 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
16336 {
16337
16338 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
16339 {
16340 int odraw = drawstyle;
16341 drawstyle = 2;
16342 drawblock(dest,15);
16343 drawstyle = odraw;
16344 }
16345 else
16346 {
16347 drawblock(dest,15);
16348 }
16349 break;
16350
16351 }
16352
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6304 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6304 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
16353 {
16354 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
16355 {
16356 int odraw = drawstyle;
16357 drawstyle = 2;
16358 drawblock(dest,15);
16359 drawstyle = odraw;
16360 }
16361 else
16362 {
16363 drawblock(dest,15);
16364 }
16365 break;
16366 }
16367
1/2
✓ Branch 0 taken 6304 times.
✗ Branch 1 not taken.
6304 if(db!=999)
16368 6304 break;
16369 [[fallthrough]];
16370 case 2:
16371
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 233 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
233 if(Stunclk<64 && (Stunclk&1))
16372 break;
16373 [[fallthrough]];
16374 case -1:
16375 1013 tile=o_tile;
16376
16377 [[fallthrough]];
16378 case 1:
16379 case 3:
16380 2621 drawblock(dest,15);
16381 2621 break;
16382
16383 case 4:
16384 320 draw_guts(dest);
16385 320 draw_flash(dest);
16386 320 break;
16387 }
16388 9247 }
16389
16390 320 void eGanon::draw_guts(BITMAP *dest)
16391 {
16392
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 68 times.
320 int32_t c = zc_min(clk>>3,8);
16393 320 tile = clk<24 ? 74 : 75;
16394 320 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
16395 320 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
16396 320 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
16397 320 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
16398 320 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
16399 320 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
16400 320 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
16401 320 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
16402 320 }
16403
16404 320 void eGanon::draw_flash(BITMAP *dest)
16405 {
16406
16407 320 int32_t c = clk-(clk>>2);
16408 320 cs = (frame&3)+6;
16409 320 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
16410 320 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
16411 320 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
16412 320 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
16413 320 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
16414 320 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
16415 320 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
16416 320 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
16417 320 }
16418
16419 4 void getBigTri(int32_t id2)
16420 {
16421 /*
16422 *************************
16423 * BIG TRIFORCE SEQUENCE *
16424 *************************
16425 0 BIGTRI out, WHITE flash in
16426 4 WHITE flash out, PILE cset white
16427 8 WHITE in
16428 ...
16429 188 WHITE out
16430 191 PILE cset red
16431 200 top SHUTTER opens
16432 209 bottom SHUTTER opens
16433 */
16434 4 sfx(itemsbuf[id2].playsound);
16435 4 guys.clear();
16436
16437
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
16438 {
16439 game->lvlitems[dlevel]|=liTRIFORCE;
16440 }
16441
16442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
16443
16444 4 draw_screen(tmpscr);
16445
16446
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 768 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 768 times.
772 for(int32_t f=0; f<24*8 && !Quit; f++)
16447 {
16448
2/2
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 4 times.
768 if(f==4)
16449 {
16450
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 4 times.
64 for(int32_t i=1; i<16; i++)
16451 {
16452 60 RAMpal[CSET(9)+i]=_RGB(63,63,63);
16453 60 }
16454 4 }
16455
16456
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 96 times.
768 if((f&7)==0)
16457 {
16458
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 96 times.
384 for(int32_t cs=2; cs<5; cs++)
16459 {
16460
2/2
✓ Branch 0 taken 4320 times.
✓ Branch 1 taken 288 times.
4608 for(int32_t i=1; i<16; i++)
16461 {
16462 4320 RAMpal[CSET(cs)+i]=_RGB(63,63,63);
16463 4320 }
16464 288 }
16465
16466 96 refreshpal=true;
16467 96 }
16468
16469
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 96 times.
768 if((f&7)==4)
16470 {
16471
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
16472 else loadlvlpal(0xB);
16473 96 }
16474
16475
2/2
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 4 times.
768 if(f==191)
16476 {
16477 4 loadpalset(9,pSprite(spPILE));
16478 4 }
16479
16480 768 advanceframe(true);
16481 768 }
16482
16483 //play_DmapMusic();
16484 4 playLevelMusic();
16485
16486
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if(itemsbuf[id2].flags & ITEM_FLAG1 && currscr < 128)
16487 {
16488 Hero.dowarp(1,0); //side warp
16489 }
16490 4 }
16491
16492 /**********************************/
16493 /*** Multiple-Segment Enemies ***/
16494 /**********************************/
16495
16496
16497 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
16498 58 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
16499 58 {
16500
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if( !(editorflags & ENEMY_FLAG5) )
16501 {
16502
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 x=128;
16503
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 y=48;
16504 29 }
16505 //else { x = X; y = Y; }
16506
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 dir=(zc_oldrand()&7)+8;
16507 29 superman=1;
16508 29 fading=fade_invisible;
16509 29 hxofs=1000;
16510 29 segcnt=clk;
16511 29 segid=Id|0x1000;
16512 29 clk=0;
16513
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 id=guys.Count();
16514
3/6
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 29 times.
✗ Branch 5 not taken.
29 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16515 29 tile=o_tile;
16516 29 hitdir = -1;
16517 29 stickclk = 0;
16518
16519 /*
16520 if (get_bit(quest_rules,qr_NEWENEMYTILES))
16521 {
16522 tile=nets+1220;
16523 }
16524 else
16525 {
16526 tile=57;
16527 }
16528 */
16529 29 }
16530
16531 27513 bool eMoldorm::animate(int32_t index)
16532 {
16533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27513 times.
27513 if(switch_hooked) return enemy::animate(index);
16534 27513 int32_t max_y = isdungeon() ? 100 : 100+28; //warning: Ugly hack. -Z
16535
2/2
✓ Branch 0 taken 19447 times.
✓ Branch 1 taken 8066 times.
27513 if ( y > (max_y) )
16536 {
16537 8066 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
16538 //Z_scripterrlog("Stickclk is %d\n", stickclk);
16539 8066 }
16540
2/2
✓ Branch 0 taken 27346 times.
✓ Branch 1 taken 167 times.
27513 if ( stickclk > 45 )
16541 {
16542 167 stickclk = 0;
16543 167 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
16544 167 }
16545
16546
16547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27513 times.
27513 if(clk==0)
16548 {
16549 27513 removearmos(x,y,ffcactivated);
16550 27513 }
16551
16552
2/2
✓ Branch 0 taken 532 times.
✓ Branch 1 taken 26981 times.
27513 if(clk2)
16553 {
16554
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 28 times.
532 if(--clk2 == 0)
16555 {
16556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(flags&guy_neverret)
16557 28 never_return(index);
16558
16559
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
28 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
16560 28 leave_item();
16561
16562 28 stop_bgsfx(index);
16563 28 return true;
16564 }
16565 504 }
16566 else
16567 {
16568
1/2
✓ Branch 0 taken 26981 times.
✗ Branch 1 not taken.
26981 if(stunclk>0)
16569 stunclk=0;
16570 26981 constant_walk_8_old(rate,homing,spw_floater);
16571
16572
16573 26981 misc=dir;
16574
16575 // If any higher-numbered segments were killed, segcnt can be too high,
16576 // leading to a crash
16577
1/2
✓ Branch 0 taken 26981 times.
✗ Branch 1 not taken.
26981 if(index+segcnt>=guys.Count())
16578 segcnt=guys.Count()-index-1;
16579
16580
2/2
✓ Branch 0 taken 26981 times.
✓ Branch 1 taken 232236 times.
259217 for(int32_t i=index+1; i<index+segcnt+1; i++)
16581 {
16582 232236 enemy* segment=((enemy*)guys.spr(i));
16583
16584 // More validation - if segcnt was wrong, this may not
16585 // actually be a Moldorm segment
16586
1/2
✓ Branch 0 taken 232236 times.
✗ Branch 1 not taken.
232236 if(segment->id!=segid)
16587 {
16588 segcnt=i-index-1;
16589 break;
16590 }
16591
16592
2/2
✓ Branch 0 taken 205217 times.
✓ Branch 1 taken 27019 times.
232236 if(i==index+1)
16593 {
16594 27019 x=segment->x;
16595 27019 y=segment->y;
16596 27019 }
16597
16598 232236 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
16599 //Script your own blasted segmented bosses!! -Z
16600 232236 segment->parent_script_UID = this->script_UID;
16601
4/4
✓ Branch 0 taken 26981 times.
✓ Branch 1 taken 205255 times.
✓ Branch 2 taken 3857 times.
✓ Branch 3 taken 23124 times.
232236 if((i==index+segcnt)&&(i!=index+1)) //tail
16602 {
16603 23124 segment->dummy_int[1]=2;
16604 23124 }
16605 else
16606 {
16607 209112 segment->dummy_int[1]=1;
16608 }
16609
16610
2/2
✓ Branch 0 taken 205217 times.
✓ Branch 1 taken 27019 times.
232236 if(i==index+1) //head
16611 {
16612 27019 segment->dummy_int[1]=0;
16613 27019 }
16614
16615
2/2
✓ Branch 0 taken 232033 times.
✓ Branch 1 taken 203 times.
232236 if(segment->hp <= 0)
16616 {
16617 203 int32_t offset=1;
16618
16619
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 405 times.
608 for(int32_t j=i; j<index+segcnt; j++)
16620 {
16621 // Triple-check
16622
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(((enemy*)guys.spr(j+1))->id!=segid)
16623 {
16624 segcnt=j-index+1; // Add 1 because of --segcnt below
16625 break;
16626 }
16627 405 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
16628 405 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
16629 405 }
16630
16631 203 segment->hclk=33;
16632 203 --segcnt;
16633 203 --i; // Recheck the same index in case multiple segments died at once
16634 203 }
16635 232236 }
16636
16637
2/2
✓ Branch 0 taken 26953 times.
✓ Branch 1 taken 28 times.
26981 if(segcnt==0)
16638 {
16639 28 clk2=19;
16640
16641 28 x=guys.spr(index+1)->x;
16642 28 y=guys.spr(index+1)->y;
16643 28 }
16644 }
16645
16646 27485 return false;
16647 27513 }
16648
16649 410 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
16650 410 {
16651
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if( !(editorflags & ENEMY_FLAG5) )
16652 {
16653
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 x=128;
16654
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 y=48;
16655 205 }
16656
16657
3/6
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 205 times.
✓ Branch 4 taken 205 times.
✗ Branch 5 not taken.
205 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16658 205 hyofs=4;
16659 205 hxsz=hysz=8;
16660 205 hxofs=1000;
16661 205 mainguy=count_enemy=false;
16662 205 parentclk = 0;
16663 205 bgsfx=-1;
16664 205 flags&=~guy_neverret;
16665 //deadsfx = WAV_EDEAD;
16666 205 isCore = false;
16667 205 }
16668
16669 235890 bool esMoldorm::animate(int32_t index)
16670 {
16671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 235890 times.
235890 if(switch_hooked) return enemy::animate(index);
16672 // Shouldn't be possible, but better to be sure
16673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 235890 times.
235890 if(index==0)
16674 dying=true;
16675
16676
2/2
✓ Branch 0 taken 3654 times.
✓ Branch 1 taken 232236 times.
235890 if(dying)
16677 {
16678
1/2
✓ Branch 0 taken 3654 times.
✗ Branch 1 not taken.
3654 if(!dmisc2)
16679 3654 item_set=0;
16680
16681 3654 return Dead(index);
16682 }
16683
16684
2/2
✓ Branch 0 taken 11638 times.
✓ Branch 1 taken 220598 times.
232236 if(clk>=0)
16685 {
16686 220598 hxofs=4;
16687 220598 step=((enemy*)guys.spr(index-1))->step;
16688
16689
2/2
✓ Branch 0 taken 19290 times.
✓ Branch 1 taken 201308 times.
220598 if(parentclk == 0)
16690 {
16691 19290 misc=dir;
16692 19290 dir=((enemy*)guys.spr(index-1))->misc;
16693 //do alignment, as in parent's animation :-/ -DD
16694 19290 x.doFloor();
16695 19290 y.doFloor();
16696 19290 }
16697
16698 220598 parentclk=(parentclk+1)%((int32_t)(8.0/step));
16699
16700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 220598 times.
220598 if(!watch)
16701 {
16702 220598 sprite::move(step);
16703 220598 }
16704 220598 }
16705
16706 232236 return enemy::animate(index);
16707 235890 }
16708
16709 1344 int32_t esMoldorm::takehit(weapon *w)
16710 {
16711
2/2
✓ Branch 0 taken 1249 times.
✓ Branch 1 taken 95 times.
1344 if(enemy::takehit(w))
16712 1249 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
16713
16714 95 return 0;
16715 1344 }
16716
16717 235890 void esMoldorm::draw(BITMAP *dest)
16718 {
16719 235890 tile=o_tile;
16720 235890 int32_t fdiv = frate/4;
16721
1/2
✓ Branch 0 taken 235890 times.
✗ Branch 1 not taken.
235890 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
16722
16723
2/2
✓ Branch 0 taken 174313 times.
✓ Branch 1 taken 61577 times.
235890 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
16724 235890 efrate:((clk>=(frate>>1))?1:0);
16725
16726
2/2
✓ Branch 0 taken 61577 times.
✓ Branch 1 taken 174313 times.
235890 if(get_bit(quest_rules,qr_NEWENEMYTILES))
16727 {
16728 174313 tile+=dummy_int[1]*40;
16729
16730
2/2
✓ Branch 0 taken 8225 times.
✓ Branch 1 taken 166088 times.
174313 if(dir<8)
16731 {
16732 8225 flip=0;
16733
2/2
✓ Branch 0 taken 6334 times.
✓ Branch 1 taken 1891 times.
8225 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
16734
16735
1/2
✓ Branch 0 taken 8225 times.
✗ Branch 1 not taken.
8225 if(dir>3) // Skip to the next row for diagonals
16736 tile+=4;
16737 8225 }
16738 else
16739 {
16740
8/9
✓ Branch 0 taken 19387 times.
✓ Branch 1 taken 21685 times.
✓ Branch 2 taken 17282 times.
✓ Branch 3 taken 23954 times.
✓ Branch 4 taken 18786 times.
✓ Branch 5 taken 18505 times.
✓ Branch 6 taken 22672 times.
✓ Branch 7 taken 23817 times.
✗ Branch 8 not taken.
166088 switch(dir-8) //directions get screwed up after 8. *shrug*
16741 {
16742 case up: //u
16743 19387 flip=0;
16744 19387 break;
16745
16746 case l_up: //d
16747 21685 flip=0;
16748 21685 tile+=4;
16749 21685 break;
16750
16751 case l_down: //l
16752 17282 flip=0;
16753 17282 tile+=8;
16754 17282 break;
16755
16756 case left: //r
16757 23954 flip=0;
16758 23954 tile+=12;
16759 23954 break;
16760
16761 case r_down: //ul
16762 18786 flip=0;
16763 18786 tile+=20;
16764 18786 break;
16765
16766 case down: //ur
16767 18505 flip=0;
16768 18505 tile+=24;
16769 18505 break;
16770
16771 case r_up: //dl
16772 22672 flip=0;
16773 22672 tile+=28;
16774 22672 break;
16775
16776 case right: //dr
16777 23817 flip=0;
16778 23817 tile+=32;
16779 23817 break;
16780 }
16781 }
16782
16783 174313 tile+=f2;
16784 174313 }
16785
16786
2/2
✓ Branch 0 taken 11692 times.
✓ Branch 1 taken 224198 times.
235890 if(clk>=0)
16787 224198 enemy::draw(dest);
16788 235890 }
16789
16790 140 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
16791 140 {
16792
1/2
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
70 if( !(editorflags & ENEMY_FLAG5) )
16793 {
16794
1/2
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
70 x=64;
16795
1/2
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
70 y=80;
16796 70 }
16797 //else { x = X; y = Y; }
16798 //zprint2("lanmola index is %d\n", index);
16799 //byte legaldirs = 0;
16800 70 int32_t incr = 16;
16801 //int32_t possiiblepos = 0;
16802 //int32_t positions[8] = {0};
16803
16804 //Don't spawn in pits.
16805
5/8
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 68 times.
✓ Branch 7 taken 2 times.
70 if ( m_walkflag_simple(x, y) )
16806 {
16807 //zprint2("Can't spawn here.\n");
16808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 for ( ; incr < 240; incr += 16 )
16809 {
16810 //move if we spawn over a pit
16811 //check each direction
16812
6/12
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
2 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
16813 {
16814 //zprint2("Spawn adjustment: -x (%d)\n", incr);
16815
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 x-=incr; break;
16816 }
16817 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
16818 {
16819 //zprint2("Spawn adjustment: +x (%d)\n", incr);
16820 x+=incr; break;
16821 }
16822 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
16823 {
16824 //zprint2("Spawn adjustment: -x (%d), -y (%d)\n", incr, incr);
16825 x-=incr; y-=incr; break;
16826 }
16827 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
16828 {
16829 //zprint2("Spawn adjustment: +x (%d), -y (%d)\n", incr, incr);
16830 x+=incr; y-=incr; break;
16831 }
16832 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
16833 {
16834 //zprint2("Spawn adjustment: -y (%d)\n", incr);
16835 y -= incr; break;
16836 }
16837 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
16838 {
16839 //zprint2("Spawn adjustment: +y (%d)\n", incr);
16840 y+=incr; break;
16841 }
16842 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
16843 {
16844 //zprint2("Spawn adjustment: -x (%d), +y (%d)\n", incr, incr);
16845 x-=incr; y+=incr; break;
16846 }
16847 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
16848 {
16849 //zprint2("Spawn adjustment: +x (%d), +y (%d)\n", incr, incr);
16850 x+=incr; y+=incr; break;
16851 }
16852 else continue;
16853
16854 }
16855
16856 2 }
16857
16858 70 dir=up;
16859 70 superman=1;
16860 70 fading=fade_invisible;
16861 70 hxofs=1000;
16862 70 segcnt=clk;
16863 70 clk=0;
16864 //set up move history
16865
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 626 times.
696 for(int32_t i=0; i <= (1<<dmisc2); i++)
16866
3/6
✓ Branch 0 taken 626 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 626 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 626 times.
✗ Branch 5 not taken.
626 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
16867 70 }
16868
16869 57879 bool eLanmola::animate(int32_t index)
16870 {
16871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57879 times.
57879 if(switch_hooked) return enemy::animate(index);
16872
2/2
✓ Branch 0 taken 50049 times.
✓ Branch 1 taken 7830 times.
57879 if(clk==0)
16873 {
16874 7830 removearmos(x,y,ffcactivated);
16875 7830 }
16876
16877
2/2
✓ Branch 0 taken 1102 times.
✓ Branch 1 taken 56777 times.
57879 if(clk2)
16878 {
16879
2/2
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 58 times.
1102 if(--clk2 == 0)
16880 {
16881
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 14 times.
58 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
16882 44 leave_item();
16883
16884 58 stop_bgsfx(index);
16885 58 return true;
16886 }
16887
16888 1044 return false;
16889 }
16890
16891
16892 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
16893 //the direction AND x,y position of the lanmola to vary in uncertain ways.
16894 //I've added a complete movement history to this enemy to compensate -DD
16895 56777 constant_walk(rate,homing,spw_none);
16896 56777 prevState.pop_front();
16897 56777 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
16898
16899 // This could cause a crash with Moldorms. I didn't see the same problem
16900 // with Lanmolas, but it looks like it ought to be possible, so here's
16901 // the same solution. - Saf
16902
1/2
✓ Branch 0 taken 56777 times.
✗ Branch 1 not taken.
56777 if(index+segcnt>=guys.Count())
16903 segcnt=guys.Count()-index-1;
16904
16905
2/2
✓ Branch 0 taken 56777 times.
✓ Branch 1 taken 309043 times.
365820 for(int32_t i=index+1; i<index+segcnt+1; i++)
16906 {
16907 309043 enemy* segment=((enemy*)guys.spr(i));
16908
16909 // More validation in case segcnt is wrong
16910
1/2
✓ Branch 0 taken 309043 times.
✗ Branch 1 not taken.
309043 if((segment->id&0xFFF)!=(id&0xFFF))
16911 {
16912 segcnt=i-index-1;
16913 break;
16914 }
16915
16916 309043 segment->o_tile=o_tile;
16917 309043 segment->parent_script_UID = this->script_UID;
16918
4/4
✓ Branch 0 taken 56777 times.
✓ Branch 1 taken 252266 times.
✓ Branch 2 taken 10177 times.
✓ Branch 3 taken 46600 times.
309043 if((i==index+segcnt)&&(i!=index+1))
16919 {
16920 46600 segment->dummy_int[1]=1; //tail
16921 46600 }
16922 else
16923 {
16924 262443 segment->dummy_int[1]=0;
16925 }
16926
16927
2/2
✓ Branch 0 taken 308687 times.
✓ Branch 1 taken 356 times.
309043 if(segment->hp <= 0)
16928 {
16929
2/2
✓ Branch 0 taken 356 times.
✓ Branch 1 taken 679 times.
1035 for(int32_t j=i; j<index+segcnt; j++)
16930 {
16931 // Triple-check
16932
1/2
✓ Branch 0 taken 679 times.
✗ Branch 1 not taken.
679 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
16933 {
16934 segcnt=j-index+1; // Add 1 because of --segcnt below
16935 break;
16936 }
16937 679 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
16938 679 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
16939 679 }
16940
16941 356 ((enemy*)guys.spr(i))->hclk=33;
16942 356 --segcnt;
16943 356 --i; // Recheck the same index in case multiple segments died at once
16944 356 }
16945 309043 }
16946
16947
2/2
✓ Branch 0 taken 56719 times.
✓ Branch 1 taken 58 times.
56777 if(segcnt==0)
16948 {
16949 58 clk2=19;
16950 58 x=guys.spr(index+1)->x;
16951 58 y=guys.spr(index+1)->y;
16952 58 setmapflag(mTMPNORET);
16953 58 }
16954
16955 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
16956 //which is... disastrous.
16957 56777 hp = 1;
16958 56777 return enemy::animate(index);
16959 57879 }
16960
16961 810 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
16962 810 {
16963
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if( !(editorflags & ENEMY_FLAG5) )
16964 {
16965
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 x=64;
16966
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 y=80;
16967 405 }
16968 405 int32_t incr = 16;
16969 //Don't spawn in pits.
16970
5/8
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 405 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 395 times.
✓ Branch 7 taken 10 times.
405 if ( m_walkflag_simple(x, y) )
16971 {
16972 //zprint2("Can't spawn here.\n");
16973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 for ( ; incr < 240; incr += 16 )
16974 {
16975 //move if we spawn over a pit
16976 //check each direction
16977
6/12
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 10 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 10 times.
✗ Branch 11 not taken.
10 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
16978 {
16979 //zprint2("Spawn adjustment: -x (%d)\n", incr);
16980
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 x-=incr; break;
16981 }
16982 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
16983 {
16984 //zprint2("Spawn adjustment: +x (%d)\n", incr);
16985 x+=incr; break;
16986 }
16987 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
16988 {
16989 //zprint2("Spawn adjustment: -x (%d), -y (%d)\n", incr, incr);
16990 x-=incr; y-=incr; break;
16991 }
16992 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
16993 {
16994 //zprint2("Spawn adjustment: +x (%d), -y (%d)\n", incr, incr);
16995 x+=incr; y-=incr; break;
16996 }
16997 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
16998 {
16999 //zprint2("Spawn adjustment: -y (%d)\n", incr);
17000 y -= incr; break;
17001 }
17002 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
17003 {
17004 //zprint2("Spawn adjustment: +y (%d)\n", incr);
17005 y+=incr; break;
17006 }
17007 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
17008 {
17009 //zprint2("Spawn adjustment: -x (%d), +y (%d)\n", incr, incr);
17010 x-=incr; y+=incr; break;
17011 }
17012 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
17013 {
17014 //zprint2("Spawn adjustment: +x (%d), +y (%d)\n", incr, incr);
17015 x+=incr; y+=incr; break;
17016 }
17017 else continue;
17018
17019 }
17020
17021 10 }
17022
17023 405 hxofs=1000;
17024 405 hxsz=8;
17025 405 mainguy=false;
17026 405 count_enemy=(id<0x2000)?true:false;
17027
17028 //set up move history
17029
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 3585 times.
3990 for(int32_t i=0; i <= (1<<dmisc2); i++)
17030
3/6
✓ Branch 0 taken 3585 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3585 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3585 times.
✗ Branch 5 not taken.
3585 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
17031
17032 405 bgsfx = -1;
17033 405 isCore = false;
17034 405 flags&=~guy_neverret;
17035 405 }
17036
17037 315451 bool esLanmola::animate(int32_t index)
17038 {
17039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315451 times.
315451 if(switch_hooked) return enemy::animate(index);
17040 // Shouldn't be possible, but who knows
17041
1/2
✓ Branch 0 taken 315451 times.
✗ Branch 1 not taken.
315451 if(index==0)
17042 dying=true;
17043
17044
2/2
✓ Branch 0 taken 6408 times.
✓ Branch 1 taken 309043 times.
315451 if(dying)
17045 {
17046 6408 xofs=0;
17047
17048
2/2
✓ Branch 0 taken 1260 times.
✓ Branch 1 taken 5148 times.
6408 if(!dmisc3)
17049 5148 item_set=0;
17050
17051 6408 return Dead(index);
17052 }
17053
17054
2/2
✓ Branch 0 taken 10360 times.
✓ Branch 1 taken 298683 times.
309043 if(clk>=0)
17055 {
17056 298683 hxofs=4;
17057
17058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 298683 times.
298683 if(!watch)
17059 {
17060 298683 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
17061 298683 prevState.pop_front();
17062 298683 prevState.push_back(newstate);
17063 298683 x = newstate.first.first;
17064 298683 y = newstate.first.second;
17065 298683 dir = newstate.second;
17066 298683 }
17067 298683 }
17068
17069 309043 return enemy::animate(index);
17070 315451 }
17071
17072 1124 int32_t esLanmola::takehit(weapon *w)
17073 {
17074
2/2
✓ Branch 0 taken 1114 times.
✓ Branch 1 taken 10 times.
1124 if(enemy::takehit(w))
17075 1114 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
17076
17077 10 return 0;
17078 1124 }
17079
17080 315432 void esLanmola::draw(BITMAP *dest)
17081 {
17082 315432 tile=o_tile;
17083 315432 int32_t fdiv = frate/4;
17084
1/2
✓ Branch 0 taken 315432 times.
✗ Branch 1 not taken.
315432 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
17085
17086
2/2
✓ Branch 0 taken 241733 times.
✓ Branch 1 taken 73699 times.
315432 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
17087 315432 efrate:((clk>=(frate>>1))?1:0);
17088
17089
2/2
✓ Branch 0 taken 241733 times.
✓ Branch 1 taken 73699 times.
315432 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17090 {
17091
2/2
✓ Branch 0 taken 37764 times.
✓ Branch 1 taken 203969 times.
241733 if(id>=0x2000)
17092 {
17093 203969 tile+=20;
17094
17095
2/2
✓ Branch 0 taken 170139 times.
✓ Branch 1 taken 33830 times.
203969 if(dummy_int[1]==1)
17096 {
17097 33830 tile+=20;
17098 33830 }
17099 203969 }
17100
17101
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 52080 times.
✓ Branch 2 taken 54498 times.
✓ Branch 3 taken 64772 times.
✓ Branch 4 taken 70383 times.
241733 switch(dir)
17102 {
17103 case up:
17104 52080 flip=0;
17105 52080 break;
17106
17107 case down:
17108 54498 flip=0;
17109 54498 tile+=4;
17110 54498 break;
17111
17112 case left:
17113 64772 flip=0;
17114 64772 tile+=8;
17115 64772 break;
17116
17117 case right:
17118 70383 flip=0;
17119 70383 tile+=12;
17120 70383 break;
17121 }
17122
17123 241733 tile+=f2;
17124 241733 }
17125 else
17126 {
17127
2/2
✓ Branch 0 taken 20051 times.
✓ Branch 1 taken 53648 times.
73699 if(id>=0x2000)
17128 {
17129 53648 tile+=1;
17130 53648 }
17131 }
17132
17133
2/2
✓ Branch 0 taken 10360 times.
✓ Branch 1 taken 305072 times.
315432 if(clk>=0)
17134 305072 enemy::draw(dest);
17135 315432 }
17136
17137 72 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
17138 72 {
17139 //these are here to bypass compiler warnings about unused arguments
17140 36 Clk=Clk;
17141 36 superman=1;
17142
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 dir=(zc_oldrand()&7)+8;
17143 36 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
17144
17145
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 36 times.
196 for(int32_t i=0; i<armcnt; i++)
17146 160 arm[i]=i;
17147
17148 36 fading=fade_blue_poof;
17149 //nets+4680;
17150 36 adjusted=false;
17151 36 SIZEflags = d->SIZEflags; //Probably will be buggy. -Z 12 AUG 2020
17152
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
36 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
17153 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
17154 // al_trace("Enemy txsz:%i\n", txsz);
17155
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
36 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
17156
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
36 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
17157
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
36 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
17158
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
36 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
17159
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
17160
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
17161 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
17162
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
36 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
17163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
17164 {
17165 yofs = d->yofs+(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17166 }
17167
17168
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
36 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
17169 36 }
17170
17171 20545 bool eManhandla::animate(int32_t index)
17172 {
17173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20545 times.
20545 if(switch_hooked) return enemy::animate(index);
17174
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 20023 times.
20545 if(dying)
17175 522 return Dead(index);
17176
17177
2/2
✓ Branch 0 taken 19269 times.
✓ Branch 1 taken 754 times.
20023 if(clk==0)
17178 {
17179 754 removearmos(x,y,ffcactivated);
17180 754 }
17181
17182
17183 // check arm status, move dead ones to end of group
17184
2/2
✓ Branch 0 taken 61452 times.
✓ Branch 1 taken 20023 times.
81475 for(int32_t i=0; i<armcnt; i++)
17185 {
17186 61452 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
17187
3/4
✓ Branch 0 taken 61452 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✓ Branch 3 taken 61320 times.
61452 if(!cur_arm || cur_arm->dying)
17188 {
17189
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 132 times.
286 for(int32_t j=i; j<armcnt-1; j++)
17190 {
17191 154 zc_swap(arm[j],arm[j+1]);
17192 154 guys.swap(index+j+1,index+j+2);
17193 154 }
17194
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
17195 {
17196 leave_item();
17197 }
17198 132 --armcnt;
17199 132 --i;
17200 132 continue;
17201 }
17202
2/2
✓ Branch 0 taken 61160 times.
✓ Branch 1 taken 160 times.
61320 if(!adjusted)
17203 {
17204
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 32 times.
160 if(!dmisc2)
17205 {
17206 128 cur_arm->o_tile=o_tile+40;
17207 128 cur_arm->parent_script_UID = this->script_UID;
17208 128 }
17209 else
17210 {
17211 32 cur_arm->o_tile=o_tile+160;
17212 32 cur_arm->parent_script_UID = this->script_UID;
17213 }
17214 160 }
17215 61320 }
17216
17217 20023 adjusted=true;
17218
17219 // move or die
17220
2/2
✓ Branch 0 taken 19994 times.
✓ Branch 1 taken 29 times.
20023 if(armcnt==0)
17221 29 hp=0;
17222 else
17223 {
17224 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
17225
1/2
✓ Branch 0 taken 19994 times.
✗ Branch 1 not taken.
19994 step=zc_min(zfix(4.5),(((!dmisc2)?4:8)-int64_t(armcnt))*0.5+zslongToFix(dstep*100));
17226 19994 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
17227
17228
2/2
✓ Branch 0 taken 18386 times.
✓ Branch 1 taken 1608 times.
19994 if(!dmisc2)
17229 {
17230
2/2
✓ Branch 0 taken 53810 times.
✓ Branch 1 taken 18386 times.
72196 for(int32_t i=0; i<armcnt; i++)
17231 {
17232
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 13024 times.
✓ Branch 2 taken 13587 times.
✓ Branch 3 taken 13709 times.
✓ Branch 4 taken 13490 times.
53810 switch(arm[i])
17233 {
17234 case 0:
17235 13024 dy1=-24;
17236 13024 break;
17237
17238 case 1:
17239 13587 dy2=31;
17240 13587 break;
17241
17242 case 2:
17243 13709 dx1=-16;
17244 13709 break;
17245
17246 case 3:
17247 13490 dx2=31;
17248 13490 break;
17249 }
17250 53810 }
17251 18386 }
17252 else
17253 {
17254 1608 dx1=-8, dy1=-16, dx2=23, dy2=23;
17255
17256
2/2
✓ Branch 0 taken 7510 times.
✓ Branch 1 taken 1608 times.
9118 for(int32_t i=0; i<armcnt; i++)
17257 {
17258
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2354 times.
✓ Branch 2 taken 1852 times.
✓ Branch 3 taken 1350 times.
✓ Branch 4 taken 1954 times.
7510 switch(arm[i]&3)
17259 {
17260 case 0:
17261 2354 dy1=-32;
17262 2354 break;
17263
17264 case 1:
17265 1852 dy2=39;
17266 1852 break;
17267
17268 case 2:
17269 1350 dx1=-24;
17270 1350 break;
17271
17272 case 3:
17273 1954 dx2=39;
17274 1954 break;
17275 }
17276 7510 }
17277 }
17278
17279 19994 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
17280
17281
2/2
✓ Branch 0 taken 61320 times.
✓ Branch 1 taken 19994 times.
81314 for(int32_t i=0; i<armcnt; i++)
17282 {
17283 61320 zfix dx=(zfix)0,dy=(zfix)0;
17284
17285
2/2
✓ Branch 0 taken 53810 times.
✓ Branch 1 taken 7510 times.
61320 if(!dmisc2)
17286 {
17287
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 13024 times.
✓ Branch 2 taken 13587 times.
✓ Branch 3 taken 13709 times.
✓ Branch 4 taken 13490 times.
53810 switch(arm[i])
17288 {
17289 case 0:
17290 13024 dy=-16;
17291 13024 break;
17292
17293 case 1:
17294 13587 dy=16;
17295 13587 break;
17296
17297 case 2:
17298 13709 dx=-16;
17299 13709 break;
17300
17301 case 3:
17302 13490 dx=16;
17303 13490 break;
17304 }
17305 53810 }
17306 else
17307 {
17308
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 898 times.
✓ Branch 2 taken 1041 times.
✓ Branch 3 taken 675 times.
✓ Branch 4 taken 977 times.
✓ Branch 5 taken 1456 times.
✓ Branch 6 taken 811 times.
✓ Branch 7 taken 675 times.
✓ Branch 8 taken 977 times.
7510 switch(arm[i])
17309 {
17310 case 0:
17311 898 dy=-24;
17312 898 dx=-8;
17313 898 break;
17314
17315 case 1:
17316 1041 dy=24;
17317 1041 dx=8;
17318 1041 break;
17319
17320 case 2:
17321 675 dx=-24;
17322 675 dy=8;
17323 675 break;
17324
17325 case 3:
17326 977 dx=24;
17327 977 dy=-8;
17328 977 break;
17329
17330 case 4:
17331 1456 dy=-24;
17332 1456 dx=8;
17333 1456 break;
17334
17335 case 5:
17336 811 dy=24;
17337 811 dx=-8;
17338 811 break;
17339
17340 case 6:
17341 675 dx=-24;
17342 675 dy=-8;
17343 675 break;
17344
17345 case 7:
17346 977 dx=24;
17347 977 dy=8;
17348 977 break;
17349 }
17350 }
17351
17352 61320 guys.spr(index+i+1)->x = x+dx;
17353 61320 guys.spr(index+i+1)->y = y+dy;
17354 61320 }
17355 }
17356
17357 20023 return enemy::animate(index);
17358 20545 }
17359
17360
17361 1162 int32_t eManhandla::takehit(weapon *w)
17362 {
17363 1162 int32_t wpnId = w->id;
17364
17365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1162 times.
1162 if(dying)
17366 return 0;
17367
17368
3/4
✓ Branch 0 taken 793 times.
✓ Branch 1 taken 359 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
1162 switch(wpnId)
17369 {
17370 case wBomb:
17371 case wSBomb:
17372 case wSword:
17373 case wHammer:
17374 case wWand:
17375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 359 times.
359 if (get_bit(quest_rules, qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
17376
17377 case wLitBomb:
17378 case wLitSBomb:
17379 case wBait:
17380 case wWhistle:
17381 case wFire:
17382 case wWind:
17383 case wSSparkle:
17384 case wFSparkle:
17385 case wPhantom:
17386 1152 return 0;
17387
17388 case wHookshot:
17389 case wBrang:
17390 sfx(WAV_CHINK,pan(int32_t(x)));
17391 break;
17392
17393 default:
17394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (get_bit(quest_rules, qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
17395 else sfx(WAV_CHINK,pan(int32_t(x)));
17396
17397 10 }
17398
17399 10 return 1;
17400 1162 }
17401
17402 20542 void eManhandla::draw(BITMAP *dest)
17403 {
17404 20542 tile=o_tile;
17405 20542 int32_t fdiv = frate/4;
17406
1/2
✓ Branch 0 taken 20542 times.
✗ Branch 1 not taken.
20542 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
17407
17408
2/2
✓ Branch 0 taken 12970 times.
✓ Branch 1 taken 7572 times.
20542 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
17409 20542 efrate:((clk>=(frate>>1))?1:0);
17410
17411
2/2
✓ Branch 0 taken 12970 times.
✓ Branch 1 taken 7572 times.
20542 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17412 {
17413
2/2
✓ Branch 0 taken 1169 times.
✓ Branch 1 taken 11801 times.
12970 if(!dmisc2)
17414 {
17415
8/9
✓ Branch 0 taken 1880 times.
✓ Branch 1 taken 1306 times.
✓ Branch 2 taken 1724 times.
✓ Branch 3 taken 1592 times.
✓ Branch 4 taken 1018 times.
✓ Branch 5 taken 1065 times.
✓ Branch 6 taken 1358 times.
✓ Branch 7 taken 1858 times.
✗ Branch 8 not taken.
11801 switch(dir-8) //directions get screwed up after 8. *shrug*
17416 {
17417 case up: //u
17418 1880 flip=0;
17419 1880 break;
17420
17421 case l_up: //d
17422 1306 flip=0;
17423 1306 tile+=4;
17424 1306 break;
17425
17426 case l_down: //l
17427 1724 flip=0;
17428 1724 tile+=8;
17429 1724 break;
17430
17431 case left: //r
17432 1592 flip=0;
17433 1592 tile+=12;
17434 1592 break;
17435
17436 case r_down: //ul
17437 1018 flip=0;
17438 1018 tile+=20;
17439 1018 break;
17440
17441 case down: //ur
17442 1065 flip=0;
17443 1065 tile+=24;
17444 1065 break;
17445
17446 case r_up: //dl
17447 1358 flip=0;
17448 1358 tile+=28;
17449 1358 break;
17450
17451 case right: //dr
17452 1858 flip=0;
17453 1858 tile+=32;
17454 1858 break;
17455 }
17456
17457 11801 tile+=f2;
17458 11801 enemy::draw(dest);
17459 11801 } //manhandla 2, big body
17460 else
17461 {
17462
17463
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
✓ Branch 2 taken 241 times.
✓ Branch 3 taken 162 times.
✓ Branch 4 taken 156 times.
✓ Branch 5 taken 93 times.
✓ Branch 6 taken 121 times.
✓ Branch 7 taken 63 times.
✓ Branch 8 taken 123 times.
1169 switch(dir-8) //directions get screwed up after 8. *shrug*
17464 {
17465 case up: //u
17466 210 flip=0;
17467 210 break;
17468
17469 case l_up: //d
17470 241 flip=0;
17471 241 tile+=8;
17472 241 break;
17473
17474 case l_down: //l
17475 162 flip=0;
17476 162 tile+=40;
17477 162 break;
17478
17479 case left: //r
17480 156 flip=0;
17481 156 tile+=48;
17482 156 break;
17483
17484 case r_down: //ul
17485 93 flip=0;
17486 93 tile+=80;
17487 93 break;
17488
17489 case down: //ur
17490 121 flip=0;
17491 121 tile+=88;
17492 121 break;
17493
17494 case r_up: //dl
17495 63 flip=0;
17496 63 tile+=120;
17497 63 break;
17498
17499 case right: //dr
17500 123 flip=0;
17501 123 tile+=128;
17502 123 break;
17503 }
17504
17505 1169 tile+=(f2*2);
17506 1169 xofs-=8;
17507 1169 yofs-=8;
17508 1169 drawblock(dest,15);
17509 1169 xofs+=8;
17510 1169 yofs+=8;
17511 }
17512 12970 }
17513 else
17514 {
17515
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 7057 times.
7572 if(!dmisc2)
17516 {
17517 7057 enemy::draw(dest);
17518 7057 }
17519 else
17520 {
17521 515 xofs-=8;
17522 515 yofs-=8;
17523 515 enemy::draw(dest);
17524 515 xofs+=16;
17525 515 enemy::draw(dest);
17526 515 yofs+=16;
17527 515 enemy::draw(dest);
17528 515 xofs-=16;
17529 515 enemy::draw(dest);
17530 515 xofs+=8;
17531 515 yofs-=8;
17532 }
17533 }
17534 20542 }
17535
17536 320 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
17537 320 {
17538 160 id=misc=clk;
17539 160 dir = clk & 3;
17540 160 clk=0;
17541 160 mainguy=count_enemy=false;
17542 160 dummy_bool[0]=false;
17543 160 item_set=0;
17544 160 bgsfx=-1;
17545 160 deadsfx = WAV_EDEAD;
17546 160 flags &= (~guy_neverret);
17547 160 isCore = false;
17548 //Probably will be buggy. -Z 12 AUG 2020
17549 160 SIZEflags = d->SIZEflags;
17550
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
160 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
17551 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
17552 // al_trace("Enemy txsz:%i\n", txsz);
17553
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
160 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
17554
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
160 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
17555
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
160 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
17556
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
160 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
17557
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
17558
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
17559 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
17560
1/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
160 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
17561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
160 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
17562 {
17563 yofs = d->yofs+(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17564 }
17565
17566
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
160 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
17567 160 }
17568
17569 63696 bool esManhandla::animate(int32_t index)
17570 {
17571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63696 times.
63696 if(switch_hooked) return enemy::animate(index);
17572
2/2
✓ Branch 0 taken 2376 times.
✓ Branch 1 taken 61320 times.
63696 if(dying)
17573 2376 return Dead(index);
17574
17575
2/2
✓ Branch 0 taken 3902 times.
✓ Branch 1 taken 57418 times.
61320 if(clk==0)
17576 {
17577 3902 removearmos(x,y,ffcactivated);
17578 3902 }
17579
17580
2/2
✓ Branch 0 taken 52486 times.
✓ Branch 1 taken 8834 times.
61320 if(--clk2<=0)
17581 {
17582 8834 clk2=unsigned(zc_oldrand())%5+5;
17583 8834 clk3^=1;
17584 8834 }
17585
17586
2/2
✓ Branch 0 taken 487 times.
✓ Branch 1 taken 60833 times.
61320 if(!(zc_oldrand()&127))
17587 {
17588 487 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
17589 487 sfx(wpnsfx(wpn),pan(int32_t(x)));
17590 487 }
17591
17592 61320 return enemy::animate(index);
17593 63696 }
17594
17595 63684 void esManhandla::draw(BITMAP *dest)
17596 {
17597 63684 tile=o_tile;
17598 63684 int32_t fdiv = frate/4;
17599
1/2
✓ Branch 0 taken 63684 times.
✗ Branch 1 not taken.
63684 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
17600
2/2
✓ Branch 0 taken 42333 times.
✓ Branch 1 taken 21351 times.
63684 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
17601 63684 efrate:((clk>=(frate>>1))?1:0);
17602
17603
2/2
✓ Branch 0 taken 42333 times.
✓ Branch 1 taken 21351 times.
63684 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17604 {
17605
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 10162 times.
✓ Branch 2 taken 10761 times.
✓ Branch 3 taken 11332 times.
✓ Branch 4 taken 10078 times.
42333 switch(misc&3)
17606 {
17607 case up:
17608 10162 break;
17609
17610 case down:
17611 10761 tile+=4;
17612 10761 break;
17613
17614 case left:
17615 11332 tile+=8;
17616 11332 break;
17617
17618 case right:
17619 10078 tile+=12;
17620 10078 break;
17621 }
17622
17623 42333 tile+=f2;
17624 42333 }
17625 else
17626 {
17627
4/5
✓ Branch 0 taken 5269 times.
✓ Branch 1 taken 5957 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5807 times.
✓ Branch 4 taken 4318 times.
21351 switch(misc&3)
17628 {
17629 case down:
17630 5269 flip=2;
17631
17632 [[fallthrough]];
17633 case up:
17634 11076 tile=(clk3)?188:189;
17635 11076 break;
17636
17637 case right:
17638 5957 flip=1;
17639 [[fallthrough]];
17640
17641 case left:
17642 10275 tile=(clk3)?186:187;
17643 10275 break;
17644 }
17645 }
17646
17647 63684 enemy::draw(dest);
17648 63684 }
17649
17650 86 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
17651 86 {
17652
1/2
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
43 if ( !(editorflags & ENEMY_FLAG5) )
17653 {
17654
1/2
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
43 x = 120;
17655
1/2
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
43 y = 48;
17656 43 }
17657 else
17658 {
17659 if ( !(editorflags & ENEMY_FLAG6) )
17660 {
17661 x = X; y = Y;
17662 }
17663 else
17664 {
17665 x = X+8; y = Y;
17666 }
17667 }
17668 43 hzsz = 32; // can't be jumped.
17669 43 flameclk=0;
17670 43 misc=clk; // total head count
17671 43 clk3=clk; // live head count
17672 43 clk=0;
17673 43 clk2=60; // fire ball clock
17674 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
17675
1/2
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
43 hp=(guysbuf[id&0xFFF].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
17676 43 dir = down;
17677 43 hxofs=4;
17678 43 hxsz=8;
17679 // frate=17*4;
17680 43 fading=fade_blue_poof;
17681 //nets+5420;
17682
3/4
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 14 times.
43 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17683 {
17684 /*
17685 necktile=o_tile+8;
17686 if (dmisc3)
17687 {
17688 necktile+=8;
17689 }
17690 */
17691 29 necktile=o_tile+dmisc6;
17692 29 }
17693 else
17694 {
17695 14 necktile=s_tile;
17696 }
17697 43 }
17698
17699 35406 bool eGleeok::animate(int32_t index)
17700 {
17701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35406 times.
35406 if(switch_hooked) return enemy::animate(index);
17702
2/2
✓ Branch 0 taken 666 times.
✓ Branch 1 taken 34740 times.
35406 if(dying)
17703 666 return Dead(index);
17704
17705
2/2
✓ Branch 0 taken 34582 times.
✓ Branch 1 taken 158 times.
34740 if(clk==0)
17706 {
17707 158 removearmos(x,y,ffcactivated);
17708 158 }
17709
17710 // Check if a head was killed somehow...
17711
2/2
✓ Branch 0 taken 22328 times.
✓ Branch 1 taken 12412 times.
34740 if(index+1+clk3>=guys.Count())
17712 12412 clk3=guys.Count()-index-1;
17713
2/2
✓ Branch 0 taken 8623 times.
✓ Branch 1 taken 26117 times.
34740 if(index+1+misc>=guys.Count())
17714 26117 misc=guys.Count()-index-1;
17715
17716 //fix for the "kill all enemies" item
17717
2/2
✓ Branch 0 taken 34734 times.
✓ Branch 1 taken 6 times.
34740 if(hp==-1000)
17718 {
17719
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
17720 {
17721 // I haven't seen this fail, but it seems like it ought to be
17722 // possible, so I'm checking for it. - Saf
17723
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
17724 break;
17725 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
17726 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
17727 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
17728 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
17729 12 }
17730
17731 6 clk3=0;
17732
17733
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
17734 {
17735
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
17736 break;
17737 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
17738 12 }
17739 6 }
17740
17741
2/2
✓ Branch 0 taken 80382 times.
✓ Branch 1 taken 34740 times.
115122 for(int32_t i=0; i<clk3; i++)
17742 {
17743 80382 enemy *head = ((enemy*)guys.spr(index+i+1));
17744 80382 head->dummy_int[1]=necktile;
17745 80382 head->parent_script_UID = this->script_UID;
17746
17747
2/2
✓ Branch 0 taken 43108 times.
✓ Branch 1 taken 37274 times.
80382 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17748 {
17749 43108 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
17750 43108 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
17751 43108 }
17752 else
17753 {
17754 37274 head->dummy_int[2]=necktile+1; //connected head tile
17755 37274 head->dummy_int[3]=necktile+2; //flying head tile
17756 }
17757
17758 80382 head->dmisc5=dmisc5; //neck segments
17759
17760 /*
17761 if (dmisc3)
17762 {
17763 head->dummy_bool[0]=true;
17764 }
17765 */
17766
2/2
✓ Branch 0 taken 78895 times.
✓ Branch 1 taken 1487 times.
80382 if(head->hclk)
17767 {
17768
2/2
✓ Branch 0 taken 1165 times.
✓ Branch 1 taken 322 times.
1487 if(hclk==0)
17769 {
17770 322 hp -= 1000 - head->hp;
17771 322 hclk = 33;
17772
17773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
322 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
17774
17775 322 sfx(WAV_EHIT,pan(int32_t(head->x)));
17776 322 }
17777
17778 1487 head->hclk = 0;
17779 1487 }
17780
17781 // Must be set in case of naughty ZScripts
17782 80382 head->hp = 1000;
17783 80382 }
17784
17785
2/2
✓ Branch 0 taken 34637 times.
✓ Branch 1 taken 103 times.
34740 if(hp<=(guysbuf[id&0xFFF].misc2)*(clk3-1)*game->get_hero_dmgmult())
17786 {
17787 103 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
17788 103 hp=(guysbuf[id&0xFFF].misc2)*(--clk3)*game->get_hero_dmgmult();
17789 103 }
17790
17791
2/2
✓ Branch 0 taken 4879 times.
✓ Branch 1 taken 29861 times.
34740 if(!dmisc3)
17792 {
17793
4/4
✓ Branch 0 taken 1640 times.
✓ Branch 1 taken 28221 times.
✓ Branch 2 taken 404 times.
✓ Branch 3 taken 1236 times.
29861 if(++clk2>72 && !(zc_oldrand()&3))
17794 {
17795 404 int32_t i=zc_oldrand()%misc;
17796 404 enemy *head = ((enemy*)guys.spr(index+i+1));
17797 404 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
17798 404 sfx(wpnsfx(wpn),pan(int32_t(x)));
17799 404 clk2=0;
17800 404 }
17801 29861 }
17802 else
17803 {
17804
4/4
✓ Branch 0 taken 191 times.
✓ Branch 1 taken 4688 times.
✓ Branch 2 taken 144 times.
✓ Branch 3 taken 47 times.
4879 if(++clk2>100 && !(zc_oldrand()&3))
17805 {
17806 47 enemy *head = ((enemy*)guys.spr(zc_oldrand()%misc+index+1));
17807 47 head->timer=zc_oldrand()%50+50;
17808 47 clk2=0;
17809 47 }
17810 }
17811
17812
3/4
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 34703 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
34740 if((hp<=0 && !immortal))
17813 {
17814
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 37 times.
134 for(int32_t i=0; i<misc; i++)
17815 97 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
17816
17817
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 34 times.
37 if(flags&guy_neverret) never_return(index);
17818 37 }
17819
17820 34740 return enemy::animate(index);
17821 35406 }
17822
17823 73 int32_t eGleeok::takehit(weapon*)
17824 {
17825 73 return 0;
17826 }
17827
17828 35529 void eGleeok::draw(BITMAP *dest)
17829 {
17830 35529 tile=o_tile;
17831
17832
2/2
✓ Branch 0 taken 666 times.
✓ Branch 1 taken 34863 times.
35529 if(dying)
17833 {
17834 666 enemy::draw(dest);
17835 666 return;
17836 }
17837
17838 34863 int32_t f=clk/17;
17839
17840
2/2
✓ Branch 0 taken 18513 times.
✓ Branch 1 taken 16350 times.
34863 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17841 {
17842 // body
17843 18513 xofs=-8;
17844 18513 yofs=32;
17845
17846
4/4
✓ Branch 0 taken 14170 times.
✓ Branch 1 taken 1479 times.
✓ Branch 2 taken 1448 times.
✓ Branch 3 taken 1416 times.
18513 switch(f)
17847
17848 {
17849 case 0:
17850 1479 tile+=0;
17851 1479 break;
17852
17853 case 1:
17854 1448 tile+=2;
17855 1448 break;
17856
17857 case 2:
17858 1416 tile+=4;
17859 1416 break;
17860
17861 default:
17862 14170 tile+=6;
17863 14170 break;
17864 }
17865 18513 }
17866 else
17867 {
17868 // body
17869 16350 xofs=-8;
17870 16350 yofs=32;
17871
17872
3/3
✓ Branch 0 taken 14042 times.
✓ Branch 1 taken 1169 times.
✓ Branch 2 taken 1139 times.
16350 switch(f)
17873 {
17874 case 0:
17875 1169 tile+=0;
17876 1169 break;
17877
17878 case 2:
17879 1139 tile+=4;
17880 1139 break;
17881
17882 default:
17883 14042 tile+=2;
17884 14042 break;
17885 }
17886 }
17887
17888 34863 enemy::drawblock(dest,15);
17889 35529 }
17890
17891 35529 void eGleeok::draw2(BITMAP *dest)
17892 {
17893 // the neck stub
17894 35529 tile=necktile;
17895 35529 xofs=0;
17896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35529 times.
35529 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17897
17898
2/2
✓ Branch 0 taken 16602 times.
✓ Branch 1 taken 18927 times.
35529 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17899 {
17900 18927 tile+=((clk&24)>>3);
17901 18927 }
17902
17903
3/4
✓ Branch 0 taken 34863 times.
✓ Branch 1 taken 666 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34863 times.
35529 if(hp > 0 && !dont_draw())
17904 {
17905
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34863 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
34863 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
17906 sprite::drawcloaked(dest);
17907 else
17908 34863 sprite::draw(dest);
17909 34863 }
17910 35529 }
17911
17912
4/8
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 133 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 133 times.
✗ Branch 7 not taken.
399 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
17913 266 {
17914
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 xoffset=0;
17915
2/4
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
133 yoffset=(zfix)((dmisc5*4+2));
17916 // dummy_bool[0]=false;
17917 133 timer=0;
17918 /* fixing */
17919 133 hp=1000;
17920
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 step=1;
17921 133 item_set=0;
17922 //x=120; y=70;
17923
4/8
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 133 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 133 times.
✗ Branch 7 not taken.
133 x = xoffset+parent->x;
17924
4/8
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 133 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 133 times.
✗ Branch 7 not taken.
133 y = yoffset+parent->y;
17925 133 hxofs=4;
17926 133 hxsz=8;
17927
3/6
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 133 times.
✓ Branch 4 taken 133 times.
✗ Branch 5 not taken.
133 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17928 133 clk2=clk; // how int32_t to wait before moving first time
17929 133 clk=0;
17930 133 mainguy=count_enemy=false;
17931
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 dir=zc_oldrand();
17932 133 clk3=((dir&2)>>1)+2; // left or right
17933 133 dir&=1; // up or down
17934
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 dmisc5=vbound(dmisc5,1,255);
17935 133 isCore = false;
17936
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 parentCore = parent->getUID();
17937
2/2
✓ Branch 0 taken 532 times.
✓ Branch 1 taken 133 times.
665 for(int32_t i=0; i<dmisc5; i++)
17938 {
17939 532 nxoffset[i] = 0;
17940 532 nyoffset[i] = 0;
17941
2/4
✓ Branch 0 taken 532 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 532 times.
✗ Branch 3 not taken.
532 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
17942
2/4
✓ Branch 0 taken 532 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 532 times.
✗ Branch 3 not taken.
532 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
17943 532 }
17944
17945 133 necktile=0;
17946 //TODO compatibility? -DD
17947 /*
17948 for(int32_t i=0; i<4; i++)
17949 {
17950 nx[i]=124;
17951 ny[i]=i*6+48;
17952 }*/
17953 133 bgsfx=-1;
17954 //no need for deadsfx
17955 133 }
17956
17957 109116 bool esGleeok::animate(int32_t index)
17958 {
17959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109116 times.
109116 if(switch_hooked) return enemy::animate(index);
17960 // don't call removearmos() - it's a segment.
17961
17962 109116 dmisc5=vbound(dmisc5,1,255);
17963
17964
2/2
✓ Branch 0 taken 28831 times.
✓ Branch 1 taken 80285 times.
109116 if(misc == 0)
17965 {
17966 80285 x = (xoffset+parent->x);
17967 80285 y = (yoffset+parent->y);
17968
17969
2/2
✓ Branch 0 taken 321140 times.
✓ Branch 1 taken 80285 times.
401425 for(int32_t i=0; i<dmisc5; i++)
17970 {
17971 321140 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
17972 321140 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
17973 321140 }
17974 80285 }
17975
17976 // set up the head tiles
17977 // headtile=nets+5588; //5580, actually. must adjust for direction later on
17978 /*
17979 if (dummy_bool[0]) //if this is a flame gleeok
17980 {
17981 headtile+=180;
17982 }
17983 */
17984 109116 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
17985 109116 flyingheadtile=dummy_int[3];
17986
17987 // set up the neck tiles
17988 109116 necktile=dummy_int[1];
17989
17990
2/2
✓ Branch 0 taken 56650 times.
✓ Branch 1 taken 52466 times.
109116 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17991 {
17992 56650 necktile+=((clk&24)>>3);
17993 56650 }
17994
17995 /*
17996 else
17997 {
17998 necktile=145;
17999 }
18000 */
18001 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
18002
18003
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 80285 times.
✓ Branch 2 taken 28644 times.
✓ Branch 3 taken 78 times.
✓ Branch 4 taken 109 times.
109116 switch(misc)
18004 {
18005 case 0: // live head
18006 // set up the attached head tiles
18007 80285 tile=headtile;
18008
18009
2/2
✓ Branch 0 taken 43055 times.
✓ Branch 1 taken 37230 times.
80285 if(get_bit(quest_rules,qr_NEWENEMYTILES))
18010 {
18011 43055 tile+=((clk&24)>>3);
18012 /*
18013 if (dummy_bool[0]) {
18014 tile+=1561;
18015 }
18016 */
18017 43055 }
18018
18019 /*
18020 else
18021 {
18022 tile=146;
18023 }
18024 */
18025
4/4
✓ Branch 0 taken 20278 times.
✓ Branch 1 taken 60007 times.
✓ Branch 2 taken 2190 times.
✓ Branch 3 taken 18088 times.
80285 if(++clk2>=0 && !(clk2&3))
18026 {
18027
2/2
✓ Branch 0 taken 17686 times.
✓ Branch 1 taken 402 times.
18088 if(y<= (int32_t)parent->y + 8) dir=down;
18028
18029
2/2
✓ Branch 0 taken 17715 times.
✓ Branch 1 taken 373 times.
18088 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
18030
18031
4/4
✓ Branch 0 taken 1914 times.
✓ Branch 1 taken 16174 times.
✓ Branch 2 taken 1857 times.
✓ Branch 3 taken 57 times.
18088 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
18032 {
18033 57 dir^=1;
18034 57 }
18035
18036 18088 zfix tempx = x;
18037 18088 zfix tempy = y;
18038
18039 18088 sprite::move(step);
18040 18088 xoffset += (x-tempx);
18041 18088 yoffset += (y-tempy);
18042
18043
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 17360 times.
18088 if(clk2>=4)
18044 {
18045 728 clk3^=1;
18046 728 clk2=-4;
18047 728 }
18048 else
18049 {
18050
2/2
✓ Branch 0 taken 17180 times.
✓ Branch 1 taken 180 times.
17360 if(x <= (int32_t)parent->x-(dmisc5*6))
18051 {
18052 180 clk3=right;
18053 180 }
18054
18055
2/2
✓ Branch 0 taken 17167 times.
✓ Branch 1 taken 193 times.
17360 if(x >= (int32_t)parent->x+(dmisc5*6))
18056 {
18057 193 clk3=left;
18058 193 }
18059
18060
4/4
✓ Branch 0 taken 11742 times.
✓ Branch 1 taken 5618 times.
✓ Branch 2 taken 11053 times.
✓ Branch 3 taken 689 times.
17360 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
18061 {
18062 689 clk3^=1; // x jig
18063 689 }
18064 else
18065 {
18066
4/4
✓ Branch 0 taken 5781 times.
✓ Branch 1 taken 10890 times.
✓ Branch 2 taken 5597 times.
✓ Branch 3 taken 184 times.
16671 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
18067 {
18068 184 clk3^=1; // x switch back
18069 184 }
18070
18071 16671 clk2=-4;
18072 }
18073 }
18074
18075 18088 zc_swap(dir,clk3);
18076 18088 tempx = x;
18077 18088 tempy = y;
18078 18088 sprite::move(step);
18079 18088 xoffset += (x-tempx);
18080 18088 yoffset += (y-tempy);
18081 18088 zc_swap(dir,clk3);
18082
18083
2/2
✓ Branch 0 taken 54264 times.
✓ Branch 1 taken 18088 times.
72352 for(int32_t i=1; i<dmisc5; i++)
18084 {
18085 54264 nxoffset[i] = (zc_oldrand()%3);
18086 54264 nyoffset[i] = (zc_oldrand()%3);
18087 54264 }
18088 18088 }
18089
18090 80285 break;
18091
18092 case 1: // flying head
18093
2/2
✓ Branch 0 taken 1518 times.
✓ Branch 1 taken 27126 times.
28644 if(clk>=0)
18094
18095 {
18096 27126 variable_walk_8(rate,homing,hrate,spw_floater);
18097 27126 }
18098
18099 28644 break;
18100
18101 // the following are messages sent from the main guy...
18102 case -1: // got chopped off
18103 {
18104 78 misc=1;
18105 78 superman=1;
18106 78 hxofs=xofs=0;
18107 78 hxsz=16;
18108 78 cs=8;
18109 78 clk=-24;
18110 78 clk2=40;
18111 78 dir=(zc_oldrand()&7)+8;
18112 78 step=8.0/9.0;
18113 }
18114 78 break;
18115
18116 case -2: // the big guy is dead
18117 109 return true;
18118 }
18119
18120
2/2
✓ Branch 0 taken 105866 times.
✓ Branch 1 taken 3141 times.
109007 if(timer)
18121 {
18122
2/2
✓ Branch 0 taken 2767 times.
✓ Branch 1 taken 374 times.
3141 if(!(timer%8))
18123 {
18124 374 FireBreath(true);
18125 374 }
18126
18127 3141 --timer;
18128 3141 }
18129
18130 109007 return enemy::animate(index);
18131 109116 }
18132
18133 1968 int32_t esGleeok::takehit(weapon *w)
18134 {
18135
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1968 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1968 if ((editorflags & ENEMY_FLAG7) && misc == 1)
18136 {
18137 int32_t wpnId = w->id;
18138
18139 if(dying)
18140 return 0;
18141
18142 switch(wpnId)
18143 {
18144 case wLitBomb:
18145 case wLitSBomb:
18146 case wBait:
18147 case wWhistle:
18148 case wFire:
18149 case wWind:
18150 case wSSparkle:
18151 case wFSparkle:
18152 case wPhantom:
18153 return 0;
18154
18155 case wHookshot:
18156 case wBrang:
18157 case wBeam:
18158 case wArrow:
18159 case wMagic:
18160 case wBomb:
18161 case wSBomb:
18162 sfx(WAV_CHINK,pan(int32_t(x)));
18163 break;
18164 default:
18165 break;
18166 }
18167
18168 return 1;
18169 }
18170 else
18171 {
18172 1968 int32_t ret = enemy::takehit(w);
18173
18174
2/2
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 1487 times.
1968 if(ret==-1)
18175 1487 return 2; // force it to wait a frame before checking sword attacks again
18176
18177 481 return ret;
18178 }
18179 1968 }
18180
18181 109218 void esGleeok::draw(BITMAP *dest)
18182 {
18183 109218 dmisc5=vbound(dmisc5,1,255);
18184
18185
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 80508 times.
✓ Branch 2 taken 28710 times.
109218 switch(misc)
18186 {
18187 case 0: //neck
18188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80508 times.
80508 if(!dont_draw())
18189 {
18190
2/2
✓ Branch 0 taken 241524 times.
✓ Branch 1 taken 80508 times.
322032 for(int32_t i=1; i<dmisc5; i++) //draw the neck
18191 {
18192
2/2
✓ Branch 0 taken 129702 times.
✓ Branch 1 taken 111822 times.
241524 if(get_bit(quest_rules,qr_NEWENEMYTILES))
18193 {
18194
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129702 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129702 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
18195 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,0);
18196 else
18197 129702 overtile16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,cs,0);
18198 129702 }
18199 else
18200 {
18201
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 111822 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
111822 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
18202 overtilecloaked16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,0);
18203 else
18204 111822 overtile16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,cs,0);
18205 }
18206 241524 }
18207 80508 }
18208
18209 80508 break;
18210
18211 case 1: //flying head
18212 28710 tile=flyingheadtile;
18213
18214
2/2
✓ Branch 0 taken 15192 times.
✓ Branch 1 taken 13518 times.
28710 if(get_bit(quest_rules,qr_NEWENEMYTILES))
18215 {
18216 13518 tile+=((clk&24)>>3);
18217 13518 break;
18218 }
18219
18220 /*
18221 else
18222 {
18223 tile=(clk&1)?147:148;
18224 break;
18225 }
18226 */
18227 15192 }
18228 109218 }
18229
18230 109218 void esGleeok::draw2(BITMAP *dest)
18231 {
18232 109218 enemy::draw(dest);
18233 109218 }
18234
18235 62 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
18236 62 {
18237
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if ( !(editorflags & ENEMY_FLAG5) )
18238 {
18239
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 x = 128;
18240
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 y = 48;
18241 31 }
18242 else { x = X; y = Y; }
18243 31 adjusted=false;
18244
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 dir=(zc_oldrand()&7)+8;
18245 //step=0.25;
18246 31 flycnt=dmisc1;
18247 31 flycnt2=dmisc2;
18248 31 loopcnt=0;
18249 31 clk4 = 0;
18250 31 clk5 = 0;
18251 31 clk6 = 0;
18252 31 clk7 = 0;
18253
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
18254 31 SIZEflags = d->SIZEflags;
18255
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
18256
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
18257 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
18258 // al_trace("Enemy txsz:%i\n", txsz);
18259
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
18260
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
18261
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = hxsz;
18262
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 else if (dmisc10 == 1) hxsz = 32;
18263
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = hysz;
18264
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
18265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
18266
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 else if (dmisc10 == 1) hxofs = -8;
18267
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
18268 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
18269
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
18270
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31 else if (dmisc10 == 1) xofs = -8;
18271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
18272 {
18273 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
18274 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
18275 }
18276
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
31 else if (dmisc10 == 1) yofs = (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)-8;
18277
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if (editorflags & ENEMY_FLAG8) misc = 1;
18278
18279
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
18280
18281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if (dmisc29 == 0)
18282 {
18283
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 19 times.
31 if(!dmisc4)
18284 {
18285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if (dmisc10) dmisc29 = (90 / 3);
18286 19 else dmisc29 = (84 / 3);
18287 19 }
18288 else
18289 {
18290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (dmisc10) dmisc29 = (90 / 2);
18291 12 else dmisc29 = (84 / 2);
18292 }
18293 31 }
18294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if (dmisc30 == 0)
18295 {
18296
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 19 times.
31 if(!dmisc4)
18297 {
18298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if (dmisc10) dmisc30 = (90 / 3)*0.5;
18299 19 else dmisc30 = (84 / 3)*0.5;
18300 19 }
18301 else
18302 {
18303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (dmisc10) dmisc30 = (90 / 2)*0.5;
18304 12 else dmisc30 = (84 / 2)*0.5;
18305 }
18306 31 }
18307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if (dmisc31 == 0)
18308 {
18309
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 19 times.
31 if(!dmisc4)
18310 {
18311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if (dmisc10) dmisc31 = (90 / 3)*2;
18312 19 else dmisc31 = (84 / 3)*2;
18313 19 }
18314 else
18315 {
18316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (dmisc10) dmisc31 = (90 / 2)*0.5;
18317 12 else dmisc31 = (84 / 2)*0.5;
18318 }
18319 31 }
18320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if (dmisc32 == 0)
18321 {
18322
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 19 times.
31 if(!dmisc4)
18323 {
18324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if (dmisc10) dmisc32 = (90 / 3);
18325 19 else dmisc32 = (84 / 3);
18326 19 }
18327 else
18328 {
18329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (dmisc10) dmisc32 = (90 / 2)*0.25;
18330 12 else dmisc32 = (84 / 2)*0.25;
18331 }
18332 31 }
18333 31 }
18334
18335 38315 bool ePatra::animate(int32_t index)
18336 {
18337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38315 times.
38315 if(switch_hooked) return enemy::animate(index);
18338
2/2
✓ Branch 0 taken 468 times.
✓ Branch 1 taken 37847 times.
38315 if(dying)
18339 {
18340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 468 times.
468 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
18341 {
18342 ((enemy*)guys.spr(i))->hp = -1000;
18343 }
18344
18345 468 return Dead(index);
18346 }
18347
18348 37847 double basesize = 84;
18349
1/2
✓ Branch 0 taken 37847 times.
✗ Branch 1 not taken.
37847 if (dmisc10) basesize = 90;
18350 37847 double halfsize = basesize / 2;
18351 37847 double quartersize = halfsize / 2;
18352 37847 double twothirdsize = (basesize / 3)*2;
18353 37847 double onethirdsize = (basesize / 3);
18354
18355
18356
2/2
✓ Branch 0 taken 7815 times.
✓ Branch 1 taken 30032 times.
37847 if(clk==0)
18357 {
18358 7815 removearmos(x,y,ffcactivated);
18359 7815 }
18360
18361
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 37847 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37847 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
37847 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
18362 {
18363
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 37847 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
37847 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
18364
1/2
✓ Branch 0 taken 37847 times.
✗ Branch 1 not taken.
37847 if (loopcnt < 0) ++clk2;
18365
2/2
✓ Branch 0 taken 37418 times.
✓ Branch 1 taken 429 times.
37847 if(++clk2>basesize)
18366 {
18367 429 clk2=0;
18368
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 429 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 429 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
429 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
18369 {
18370
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 204 times.
429 if(loopcnt > 0)
18371 225 --loopcnt;
18372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
204 else if (loopcnt == 0)
18373 {
18374
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 77 times.
204 if((misc%dmisc6)==0)
18375 {
18376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if (dmisc21 > 0) loopcnt=-dmisc21;
18377 77 else loopcnt=dmisc7;
18378 77 }
18379 204 }
18380 else if (loopcnt == -1) loopcnt=dmisc7;
18381 else ++loopcnt;
18382
18383
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 429 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
429 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
18384 429 }
18385 else
18386 {
18387 loopcnt = 0;
18388 misc = 1;
18389 }
18390 429 }
18391 37847 }
18392
1/2
✓ Branch 0 taken 37847 times.
✗ Branch 1 not taken.
37847 if (clk4 > 0) --clk4;
18393
18394 37847 double size=1;
18395
18396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37847 times.
37847 if (clk6 < 0)
18397 {
18398 if (dmisc5 == 1 || dmisc5 == 3)
18399 {
18400 if (get_bit(quest_rules,qr_NEWENEMYTILES))
18401 {
18402 if (clk7 <= 0 || clk6 != -16) ++clk6;
18403 if (clk6 == 0) o_tile=d->e_tile;
18404 else
18405 {
18406 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
18407 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
18408 }
18409 }
18410 else clk6 = 0;
18411 }
18412 }
18413
1/2
✓ Branch 0 taken 37847 times.
✗ Branch 1 not taken.
37847 else if (dmisc19) ++clk6;
18414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37847 times.
37847 if (clk5 < 0) ++clk5;
18415
1/2
✓ Branch 0 taken 37847 times.
✗ Branch 1 not taken.
37847 else if (dmisc19) ++clk5;
18416
18417
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 37847 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
37847 if (clk7 > 0 && clk6 >= -16) --clk7;
18418
1/2
✓ Branch 0 taken 37847 times.
✗ Branch 1 not taken.
37847 if (clk6 > 0) clk7 = 0;
18419
18420
2/2
✓ Branch 0 taken 152037 times.
✓ Branch 1 taken 37847 times.
189884 for(int32_t i=index+1; i<index+flycnt+1; i++)
18421 {
18422 //outside ring
18423
2/2
✓ Branch 0 taken 151789 times.
✓ Branch 1 taken 248 times.
152037 if(!adjusted)
18424 {
18425
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 88 times.
248 if(get_bit(quest_rules,qr_NEWENEMYTILES))
18426 {
18427 160 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
18428 160 enemy *s = ((enemy*)guys.spr(i));
18429 160 s->parent_script_UID = this->script_UID;
18430 160 }
18431 else
18432 {
18433 88 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
18434 88 enemy *s = ((enemy*)guys.spr(i));
18435 88 s->parent_script_UID = this->script_UID;
18436 }
18437
18438 248 ((enemy*)guys.spr(i))->cs=dmisc9;
18439 248 ((enemy*)guys.spr(i))->hp=dmisc3;
18440 248 }
18441
18442
2/2
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 151829 times.
152037 if(((enemy*)guys.spr(i))->hp <= 0)
18443 {
18444
2/2
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 208 times.
877 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
18445 {
18446 669 guys.swap(j,j+1);
18447 669 }
18448
18449
3/4
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 182 times.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
208 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
18450 208 }
18451 else
18452 {
18453 151829 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
18454
1/2
✓ Branch 0 taken 151829 times.
✗ Branch 1 not taken.
151829 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
18455
18456
2/2
✓ Branch 0 taken 63320 times.
✓ Branch 1 taken 88509 times.
151829 if(!dmisc4) //Big Ring
18457 {
18458 //maybe playing_field_offset here?
18459
2/2
✓ Branch 0 taken 40273 times.
✓ Branch 1 taken 48236 times.
88509 if(loopcnt>0)
18460 {
18461
1/2
✓ Branch 0 taken 48236 times.
✗ Branch 1 not taken.
48236 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
18462
1/2
✓ Branch 0 taken 48236 times.
✗ Branch 1 not taken.
48236 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
18463 48236 }
18464 else
18465 {
18466 40273 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
18467 40273 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
18468 }
18469
18470 88509 temp_x=guys.spr(i)->x;
18471 88509 temp_y=guys.spr(i)->y;
18472 88509 }
18473 else //Oval
18474 {
18475 63320 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
18476 63320 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
18477
18478
2/2
✓ Branch 0 taken 36080 times.
✓ Branch 1 taken 27240 times.
63320 if(loopcnt>0)
18479 {
18480 36080 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
18481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36080 times.
36080 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
18482 36080 }
18483 else
18484 {
18485 27240 guys.spr(i)->x = circle_x;
18486 27240 guys.spr(i)->y = circle_y;
18487 }
18488
18489 63320 temp_x=circle_x;
18490 63320 temp_y=circle_y;
18491 }
18492
18493 double _MSVC2022_tmp1, _MSVC2022_tmp2;
18494 151829 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
18495
18496
4/4
✓ Branch 0 taken 28787 times.
✓ Branch 1 taken 123042 times.
✓ Branch 2 taken 9539 times.
✓ Branch 3 taken 19248 times.
151829 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
18497 {
18498 19248 guys.spr(i)->dir=l_down;
18499 19248 }
18500
4/4
✓ Branch 0 taken 28916 times.
✓ Branch 1 taken 103665 times.
✓ Branch 2 taken 9539 times.
✓ Branch 3 taken 19377 times.
132581 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
18501 {
18502 19377 guys.spr(i)->dir=left;
18503 19377 }
18504
4/4
✓ Branch 0 taken 28730 times.
✓ Branch 1 taken 84474 times.
✓ Branch 2 taken 9539 times.
✓ Branch 3 taken 19191 times.
113204 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
18505 {
18506 19191 guys.spr(i)->dir=l_up;
18507 19191 }
18508
4/4
✓ Branch 0 taken 28582 times.
✓ Branch 1 taken 65431 times.
✓ Branch 2 taken 9539 times.
✓ Branch 3 taken 19043 times.
94013 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
18509 {
18510 19043 guys.spr(i)->dir=up;
18511 19043 }
18512
4/4
✓ Branch 0 taken 28355 times.
✓ Branch 1 taken 46615 times.
✓ Branch 2 taken 9539 times.
✓ Branch 3 taken 18816 times.
74970 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
18513 {
18514 18816 guys.spr(i)->dir=r_up;
18515 18816 }
18516
4/4
✓ Branch 0 taken 28215 times.
✓ Branch 1 taken 27939 times.
✓ Branch 2 taken 9539 times.
✓ Branch 3 taken 18676 times.
56154 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
18517 {
18518 18676 guys.spr(i)->dir=right;
18519 18676 }
18520
4/4
✓ Branch 0 taken 28093 times.
✓ Branch 1 taken 9385 times.
✓ Branch 2 taken 9539 times.
✓ Branch 3 taken 18554 times.
37478 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
18521 {
18522 18554 guys.spr(i)->dir=r_down;
18523 18554 }
18524 else
18525 {
18526 18924 guys.spr(i)->dir=down;
18527 }
18528
18529 151829 guys.spr(i)->x += x;
18530 151829 guys.spr(i)->y += y;
18531 }
18532 152037 }
18533
18534
7/22
✓ Branch 0 taken 26681 times.
✓ Branch 1 taken 11166 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26681 times.
✓ Branch 4 taken 393 times.
✓ Branch 5 taken 10773 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 393 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 10773 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
37847 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
18535 {
18536 10773 int timeneeded = 48;
18537 10773 int patbreath = (zc_oldrand()%50+50);
18538
2/2
✓ Branch 0 taken 8202 times.
✓ Branch 1 taken 2571 times.
10773 if ((patbreath % 4) == 0) ++patbreath;
18539
1/2
✓ Branch 0 taken 10773 times.
✗ Branch 1 not taken.
10773 if (dmisc28 == patratBREATH)
18540 {
18541 timeneeded = 48 + patbreath;
18542 }
18543
1/2
✓ Branch 0 taken 10773 times.
✗ Branch 1 not taken.
10773 if (dmisc28 == patratSTREAM)
18544 {
18545 timeneeded = 48 + 96;
18546 }
18547
4/14
✓ Branch 0 taken 10773 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10773 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 91 times.
✓ Branch 11 taken 91 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
10773 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
18548
2/2
✓ Branch 0 taken 10773 times.
✓ Branch 1 taken 91 times.
10864 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
18549
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 10682 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
10864 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_bit(quest_rules,qr_NEWENEMYTILES))
18550 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES)))))
18551 91 && (clk6 >= 0) //if not in the middle of firing...
18552 91 && clk6 >= dmisc19) //if over the set cooldown between shots...
18553
2/6
✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 91 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
91 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
18554 {
18555
1/3
✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
91 switch(dmisc28)
18556 {
18557 case patratSTREAM:
18558 {
18559 clk7 = 97;
18560 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES)) clk6 = -48;
18561 else clk6 = 0;
18562 break;
18563 }
18564 case patratBREATH:
18565 {
18566 clk7 = patbreath;
18567 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES)) clk6 = -48;
18568 else clk6 = 0;
18569 break;
18570 }
18571 default:
18572 {
18573
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 91 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
91 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES))
18574 {
18575 clk6 = -48;
18576 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
18577 }
18578 else
18579 {
18580 91 clk6 = 0;
18581
1/2
✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
91 if (editorflags & ENEMY_FLAG6) clk4 = 16;
18582 91 FirePatraWeapon();
18583 }
18584 91 break;
18585 }
18586 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
18587 91 }
18588
1/2
✓ Branch 0 taken 10773 times.
✗ Branch 1 not taken.
10773 if (clk6 < 0)
18589 {
18590 switch(dmisc28)
18591 {
18592 case patratSTREAM:
18593 {
18594 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
18595 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
18596 break;
18597 }
18598 case patratBREATH:
18599 {
18600 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
18601 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
18602 break;
18603 }
18604 default:
18605 {
18606 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES) && clk6 == -16)
18607 {
18608 FirePatraWeapon();
18609 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
18610 }
18611 break;
18612 }
18613 }
18614 }
18615 10773 }
18616
18617 37847 size=.5;
18618 37847 int randattempts = 0;
18619 37847 int randeye = 0;
18620
2/2
✓ Branch 0 taken 30535 times.
✓ Branch 1 taken 7312 times.
37847 if (flycnt2 > 0)
18621 {
18622 7312 do
18623 {
18624
2/4
✓ Branch 0 taken 7312 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7312 times.
7312 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
18625 7312 randeye += (index + flycnt + 1);
18626 7312 ++randattempts;
18627
2/4
✓ Branch 0 taken 7312 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7312 times.
7312 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
18628 7312 }
18629 37847 bool dofire = false;
18630
1/2
✓ Branch 0 taken 37847 times.
✗ Branch 1 not taken.
37847 if (dmisc20)
18631 {
18632 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
18633 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
18634 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_bit(quest_rules,qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
18635 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES) || dmisc20 == 2))
18636 || ((((((misc%dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
18637 {
18638 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_bit(quest_rules,qr_NEWENEMYTILES))
18639 {
18640 if (clk5 >= dmisc19)
18641 {
18642 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
18643 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
18644 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + 96)) ||
18645 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48)))
18646 || dmisc18 == -1)
18647 dofire = true;
18648 }
18649 }
18650 }
18651 }
18652
2/2
✓ Branch 0 taken 30535 times.
✓ Branch 1 taken 7312 times.
37847 if(flycnt2)
18653 {
18654
2/2
✓ Branch 0 taken 54445 times.
✓ Branch 1 taken 7312 times.
61757 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
18655 {
18656
2/2
✓ Branch 0 taken 54405 times.
✓ Branch 1 taken 40 times.
54445 if(!adjusted)
18657 {
18658 40 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
18659
18660
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(get_bit(quest_rules,qr_NEWENEMYTILES))
18661 {
18662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if (get_bit(quest_rules,qr_PATRAS_USE_HARDCODED_OFFSETS))
18663 {
18664
2/3
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
40 switch(dmisc5)
18665 {
18666 // Center eye shoots projectiles; make room for its firing tiles
18667 case 1:
18668 case 3:
18669 32 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
18670 32 break;
18671
18672 // Center eyes does not shoot; use tiles two rows below for inner eyes.
18673 default:
18674 case 2:
18675 8 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
18676 8 break;
18677 }
18678 40 }
18679 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
18680 40 }
18681 else
18682 {
18683 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
18684 }
18685
18686 40 ((enemy*)guys.spr(i))->cs=dmisc9;
18687
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
18688 40 }
18689
18690
2/2
✓ Branch 0 taken 43872 times.
✓ Branch 1 taken 10573 times.
54445 if(flycnt>0)
18691 {
18692 43872 ((enemy*)guys.spr(i))->superman=true;
18693 43872 }
18694 else
18695 {
18696 10573 ((enemy*)guys.spr(i))->superman=false;
18697 }
18698
18699
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 54413 times.
54445 if(((enemy*)guys.spr(i))->hp <= 0)
18700 {
18701
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 32 times.
94 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
18702 {
18703 62 guys.swap(j,j+1);
18704 62 }
18705
18706
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
32 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
18707 32 }
18708 else
18709 {
18710 54413 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
18711
1/2
✓ Branch 0 taken 54413 times.
✗ Branch 1 not taken.
54413 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
18712
18713
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 47154 times.
54413 if(dmisc4==0)
18714 {
18715
2/2
✓ Branch 0 taken 24993 times.
✓ Branch 1 taken 22161 times.
47154 if(loopcnt>0)
18716 {
18717
1/2
✓ Branch 0 taken 24993 times.
✗ Branch 1 not taken.
24993 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
18718
1/2
✓ Branch 0 taken 24993 times.
✗ Branch 1 not taken.
24993 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
18719 24993 }
18720 else
18721 {
18722 22161 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
18723 22161 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
18724 }
18725
18726 47154 temp_x=guys.spr(i)->x;
18727 47154 temp_y=guys.spr(i)->y;
18728 47154 }
18729 else
18730 {
18731 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
18732 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
18733
18734
2/2
✓ Branch 0 taken 3294 times.
✓ Branch 1 taken 3965 times.
7259 if(loopcnt>0)
18735 {
18736 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
18737
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
18738 3965 }
18739 else
18740 {
18741 3294 guys.spr(i)->x = circle_x;
18742 3294 guys.spr(i)->y = circle_y;
18743 }
18744
18745 7259 temp_x=circle_x;
18746 7259 temp_y=circle_y;
18747 }
18748
18749 double _MSVC2022_tmp1, _MSVC2022_tmp2;
18750 54413 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
18751
18752
4/4
✓ Branch 0 taken 10107 times.
✓ Branch 1 taken 44306 times.
✓ Branch 2 taken 3329 times.
✓ Branch 3 taken 6778 times.
54413 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
18753 {
18754 6778 guys.spr(i)->dir=l_down;
18755 6778 }
18756
4/4
✓ Branch 0 taken 10082 times.
✓ Branch 1 taken 37553 times.
✓ Branch 2 taken 3329 times.
✓ Branch 3 taken 6753 times.
47635 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
18757 {
18758 6753 guys.spr(i)->dir=left;
18759 6753 }
18760
4/4
✓ Branch 0 taken 10084 times.
✓ Branch 1 taken 30798 times.
✓ Branch 2 taken 3329 times.
✓ Branch 3 taken 6755 times.
40882 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
18761 {
18762 6755 guys.spr(i)->dir=l_up;
18763 6755 }
18764
4/4
✓ Branch 0 taken 10105 times.
✓ Branch 1 taken 24022 times.
✓ Branch 2 taken 3329 times.
✓ Branch 3 taken 6776 times.
34127 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
18765 {
18766 6776 guys.spr(i)->dir=up;
18767 6776 }
18768
4/4
✓ Branch 0 taken 10152 times.
✓ Branch 1 taken 17199 times.
✓ Branch 2 taken 3329 times.
✓ Branch 3 taken 6823 times.
27351 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
18769 {
18770 6823 guys.spr(i)->dir=r_up;
18771 6823 }
18772
4/4
✓ Branch 0 taken 10178 times.
✓ Branch 1 taken 10350 times.
✓ Branch 2 taken 3329 times.
✓ Branch 3 taken 6849 times.
20528 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
18773 {
18774 6849 guys.spr(i)->dir=right;
18775 6849 }
18776
4/4
✓ Branch 0 taken 10175 times.
✓ Branch 1 taken 3504 times.
✓ Branch 2 taken 3329 times.
✓ Branch 3 taken 6846 times.
13679 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
18777 {
18778 6846 guys.spr(i)->dir=r_down;
18779 6846 }
18780 else
18781 {
18782 6833 guys.spr(i)->dir=down;
18783 }
18784
18785 54413 guys.spr(i)->x += x;
18786 54413 guys.spr(i)->y = y-guys.spr(i)->y;
18787
18788
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 54413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 51269 times.
✓ Branch 5 taken 3144 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 51269 times.
54413 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
18789 {
18790 /*
18791 if(!(zc_oldrand()&127))
18792 {
18793 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
18794 sfx(wpnsfx(wpn),pan(int32_t(x)));
18795 }
18796 */
18797
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3144 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3144 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
18798 {
18799 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
18800 if (get_bit(quest_rules,qr_PATRAS_USE_HARDCODED_OFFSETS))
18801 {
18802 if (dmisc5 == 3)
18803 {
18804 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
18805 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
18806 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
18807 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
18808 }
18809 else
18810 {
18811 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
18812 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
18813 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
18814 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
18815 }
18816 }
18817 else
18818 {
18819 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
18820 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
18821 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
18822 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
18823 }
18824 }
18825
4/6
✓ Branch 0 taken 3144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3144 times.
✓ Branch 4 taken 3144 times.
✓ Branch 5 taken 3144 times.
3144 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
18826
1/2
✓ Branch 0 taken 3144 times.
✗ Branch 1 not taken.
3144 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
18827
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3144 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3144 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
18828 {
18829
1/5
✓ Branch 0 taken 3144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
3144 switch(dmisc20) //Patra Attack Patterns
18830 {
18831 case 4: //Single one rapidfires
18832 {
18833 if (dofire && i == randeye)
18834 {
18835 ((esPatra*)guys.spr(i))->clk5 = -16;
18836 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
18837 ((esPatra*)guys.spr(i))->clk4 = 96;
18838 clk5 = -3;
18839 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
18840 }
18841 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
18842 {
18843 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18844 sfx(wpnsfx(wpn),pan(int32_t(x)));
18845 }
18846 break;
18847 }
18848 case 3: //Ring
18849 {
18850 if (dofire)
18851 {
18852 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES))
18853 {
18854 ((esPatra*)guys.spr(i))->clk5 = -48;
18855 clk5 = -48;
18856 if (editorflags & ENEMY_FLAG6) clk4 = 64;
18857 }
18858 else
18859 {
18860 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18861 sfx(wpnsfx(wpn),pan(int32_t(x)));
18862 int32_t m=Ewpns.Count()-1;
18863 weapon *ew = (weapon*)(Ewpns.spr(m));
18864
18865 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
18866 ((esPatra*)guys.spr(i))->clk5 = 0;
18867 clk5 = 0;
18868 if (editorflags & ENEMY_FLAG6) clk4 = 16;
18869 }
18870 }
18871 if (((esPatra*)guys.spr(i))->clk5 == -16)
18872 {
18873 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18874 sfx(wpnsfx(wpn),pan(int32_t(x)));
18875 int32_t m=Ewpns.Count()-1;
18876 weapon *ew = (weapon*)(Ewpns.spr(m));
18877
18878 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
18879 }
18880 break;
18881 }
18882 case 2: //one after another
18883 {
18884 if (dofire)
18885 {
18886 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
18887 clk5 = -48 - (12*flycnt2);
18888 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
18889 }
18890 if (((esPatra*)guys.spr(i))->clk5 == -16)
18891 {
18892 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18893 sfx(wpnsfx(wpn),pan(int32_t(x)));
18894 }
18895 break;
18896 }
18897 case 1: //random one eye
18898 {
18899 if (dofire && i == randeye)
18900 {
18901 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES))
18902 {
18903 ((esPatra*)guys.spr(i))->clk5 = -48;
18904 clk5 = -48;
18905 if (editorflags & ENEMY_FLAG6) clk4 = 64;
18906 }
18907 else
18908 {
18909 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18910 sfx(wpnsfx(wpn),pan(int32_t(x)));
18911 ((esPatra*)guys.spr(i))->clk5 = 0;
18912 clk5 = 0;
18913 if (editorflags & ENEMY_FLAG6) clk4 = 16;
18914 }
18915 }
18916 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
18917 {
18918 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18919 sfx(wpnsfx(wpn),pan(int32_t(x)));
18920 }
18921 break;
18922 }
18923 default: //old behavior, all eyes can fire any time
18924 {
18925
3/8
✓ Branch 0 taken 3144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 29 times.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3144 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
18926
3/6
✓ Branch 0 taken 3144 times.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3202 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_bit(quest_rules,qr_NEWENEMYTILES))
18927
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
29 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
18928 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48))))
18929 {
18930
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
29 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES))
18931 {
18932 ((esPatra*)guys.spr(i))->clk5 = -48;
18933 if (editorflags & ENEMY_FLAG6) clk4 = 64;
18934 }
18935 else
18936 {
18937 29 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
18938 29 sfx(wpnsfx(wpn),pan(int32_t(x)));
18939 29 ((esPatra*)guys.spr(i))->clk5 = 0;
18940
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if (editorflags & ENEMY_FLAG6) clk4 = 16;
18941 }
18942 29 }
18943
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3144 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3202 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
18944 {
18945 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
18946 sfx(wpnsfx(wpn),pan(int32_t(x)));
18947 }
18948 3144 break;
18949 }
18950 }
18951 3144 }
18952 3144 }
18953
18954 }
18955 54445 }
18956 7312 }
18957
18958 37847 adjusted=true;
18959 37847 return enemy::animate(index);
18960 38315 }
18961
18962 91 void ePatra::FirePatraWeapon()
18963 { //.707
18964 91 int32_t xoff = 0;
18965 91 int32_t yoff = 0;
18966
1/2
✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
91 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH )
18967 {
18968 xoff += (hxsz/2)-8;
18969 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
18970 }
18971
1/2
✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
91 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT )
18972 {
18973 yoff += (hysz/2)-8;
18974 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
18975 }
18976 91 sfx(wpnsfx(wpn),pan(int32_t(x)));
18977
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 91 times.
91 switch (dmisc28)
18978 {
18979 case patrat8SHOT: //Fire Wizzrobe
18980 case patrat4SHOTDIAG:
18981 case patrat4SHOTRAND:
18982 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
18983 {
18984 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
18985 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
18986 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
18987 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
18988
18989 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
18990 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
18991 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
18992 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
18993
18994 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
18995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
18996 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
18997 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
18998
18999 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
19000 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19001 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
19002 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
19003
19004 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
19005 }
19006
19007 [[fallthrough]];
19008 case patrat4SHOTCARD: //Stalfos 3
19009 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
19010 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19011 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
19012 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
19013 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19014 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
19015 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
19016 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19017 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
19018 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
19019 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19020 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
19021 break;
19022
19023 default:
19024 91 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
19025
1/2
✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
91 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
19026 91 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
19027
3/6
✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 91 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 91 times.
91 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
19028
4/8
✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 91 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 91 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 91 times.
91 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
19029 {
19030 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
19031 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
19032 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
19033 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
19034 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
19035 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
19036 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
19037 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
19038 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
19039 {
19040 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
19041 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
19042 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
19043 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
19044 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
19045 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
19046 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
19047 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
19048 }
19049 }
19050 91 break;
19051
19052 }
19053 91 sfx(wpnsfx(wpn),pan(int32_t(x)));
19054 //+0.46364761
19055 //11.80
19056 91 }
19057
19058 76794 void ePatra::draw(BITMAP *dest)
19059 {
19060 76794 tile=o_tile;
19061 76794 update_enemy_frame();
19062 76794 enemy::draw(dest);
19063 76794 }
19064
19065 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
19066 {
19067 int32_t ret = enemy::defend(wpnId, power, edef);
19068
19069 if(ret < 0 && (flycnt||flycnt2))
19070 return 0;
19071
19072 return ret;
19073 }
19074
19075 375 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
19076 {
19077 375 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
19078
19079
5/6
✓ Branch 0 taken 375 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 207 times.
✓ Branch 4 taken 76 times.
✓ Branch 5 taken 92 times.
375 if(ret < 0 && (flycnt||flycnt2))
19080 283 return 0;
19081
19082 92 return ret;
19083 375 }
19084
19085 864 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
19086 576 {
19087 //cs=8;
19088 288 item_set=0;
19089 288 misc=clk;
19090 288 clk4 = 0;
19091 288 clk5 = 0;
19092 288 clk = -((misc*21)>>1)-1;
19093
3/6
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 288 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 288 times.
✗ Branch 5 not taken.
288 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
19094 288 hxsz=12;
19095 288 hysz=12;
19096 288 hxofs=2;
19097 288 hyofs=2;
19098 288 extend = 0;
19099 288 txsz = 1;
19100 288 tysz = 1;
19101 /* //These need to be separate enemy editor fields. This enemy class also it's draw altered to correctly support big stuff.
19102 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
19103 int32_t prntSIZEflags = prntenemy->SIZEflags;
19104 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
19105 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
19106 // al_trace("Enemy txsz:%i\n", txsz);
19107 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
19108 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
19109 else
19110 hxsz=12;
19111 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
19112 else
19113 hysz=12;
19114 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
19115 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
19116 else
19117 hxofs=2;
19118 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
19119 else hyofs=2;
19120 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
19121 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
19122 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
19123 {
19124 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
19125 }
19126
19127 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
19128 */
19129 288 mainguy=count_enemy=false;
19130 288 bgsfx=-1;
19131 //o_tile=0;
19132 288 flags &= (~guy_neverret);
19133 288 deadsfx = WAV_EDEAD;
19134 288 hitsfx = WAV_EHIT;
19135 288 isCore = false;
19136 288 }
19137
19138 210961 bool esPatra::animate(int32_t index)
19139 {
19140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210961 times.
210961 if(switch_hooked) return enemy::animate(index);
19141
2/2
✓ Branch 0 taken 4320 times.
✓ Branch 1 taken 206641 times.
210961 if(dying)
19142 4320 return Dead(index);
19143
19144 206641 return enemy::animate(index);
19145 210961 }
19146
19147 424434 void esPatra::draw(BITMAP *dest)
19148 {
19149
2/2
✓ Branch 0 taken 288454 times.
✓ Branch 1 taken 135980 times.
424434 if(get_bit(quest_rules,qr_NEWENEMYTILES))
19150 {
19151 288454 tile = o_tile+(clk&3);
19152
19153
8/9
✓ Branch 0 taken 35804 times.
✓ Branch 1 taken 36902 times.
✓ Branch 2 taken 35966 times.
✓ Branch 3 taken 35672 times.
✓ Branch 4 taken 35766 times.
✓ Branch 5 taken 36110 times.
✓ Branch 6 taken 36604 times.
✓ Branch 7 taken 35630 times.
✗ Branch 8 not taken.
288454 switch(dir) //directions get screwed up after 8. *shrug*
19154 {
19155 case up: //u
19156 35804 flip=0;
19157 35804 break;
19158
19159 case down: //d
19160 36902 flip=0;
19161 36902 tile+=4;
19162 36902 break;
19163
19164 case left: //l
19165 35966 flip=0;
19166 35966 tile+=8;
19167 35966 break;
19168
19169 case right: //r
19170 35672 flip=0;
19171 35672 tile+=12;
19172 35672 break;
19173
19174 case l_up: //ul
19175 35766 flip=0;
19176 35766 tile+=20;
19177 35766 break;
19178
19179 case r_up: //ur
19180 36110 flip=0;
19181 36110 tile+=24;
19182 36110 break;
19183
19184 case l_down: //dl
19185 36604 flip=0;
19186 36604 tile+=28;
19187 36604 break;
19188
19189 case r_down: //dr
19190 35630 flip=0;
19191 35630 tile+=32;
19192 35630 break;
19193 }
19194 288454 }
19195 else
19196 {
19197 135980 tile = o_tile+((clk&2)>>1);
19198 }
19199
19200
2/2
✓ Branch 0 taken 21568 times.
✓ Branch 1 taken 402866 times.
424434 if(clk>=0)
19201 402866 enemy::draw(dest);
19202 424434 }
19203
19204
19205 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
19206 {
19207 adjusted=false;
19208 dir=(zc_oldrand()&7)+8;
19209 step=0.25;
19210 clk4 = 0;
19211 clk5 = 0;
19212 //flycnt=6; flycnt2=0;
19213 flycnt=dmisc1;
19214 flycnt2=0; // PatraBS doesn't have inner rings!
19215 loopcnt=0;
19216
19217 SIZEflags = d->SIZEflags;
19218 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
19219 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
19220 // al_trace("Enemy txsz:%i\n", txsz);
19221 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
19222 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
19223 else hxsz = 32;
19224 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
19225 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
19226 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
19227 else hxofs=-8;
19228 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
19229 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
19230 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
19231 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
19232 {
19233 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
19234 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
19235 }
19236
19237 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
19238
19239 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
19240
19241 //nets+4480;
19242 }
19243
19244 bool ePatraBS::animate(int32_t index)
19245 {
19246 if(switch_hooked) return enemy::animate(index);
19247 if(dying)
19248 return Dead(index);
19249
19250 if(clk==0)
19251 {
19252 removearmos(x,y,ffcactivated);
19253 }
19254
19255 variable_walk_8(rate,homing,hrate,spw_floater);
19256
19257 if(++clk2>90)
19258 {
19259 clk2=0;
19260
19261 if(loopcnt)
19262 --loopcnt;
19263 else
19264 {
19265 if((misc%dmisc6)==0)
19266 loopcnt=dmisc7;
19267 }
19268
19269 ++misc;
19270 }
19271
19272 // double size=1;;
19273 for(int32_t i=index+1; i<index+flycnt+1; i++)
19274 {
19275 if(!adjusted)
19276 {
19277 ((enemy*)guys.spr(i))->hp=dmisc3;
19278
19279 if(get_bit(quest_rules,qr_NEWENEMYTILES))
19280 {
19281 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
19282 }
19283 else
19284 {
19285 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
19286 }
19287
19288 ((enemy*)guys.spr(i))->cs = dmisc9;
19289 }
19290
19291 if(((enemy*)guys.spr(i))->hp <= 0)
19292 {
19293 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
19294 {
19295 guys.swap(j,j+1);
19296 }
19297
19298 --flycnt;
19299 }
19300 else
19301 {
19302 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
19303 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
19304 temp_x = zc::math::Cos(a2+PI/2)*45;
19305 temp_y = -zc::math::Sin(a2+PI/2)*45;
19306
19307 if(loopcnt>0)
19308 {
19309 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
19310 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
19311 }
19312 else
19313 {
19314 guys.spr(i)->x = temp_x;
19315 guys.spr(i)->y = temp_y;
19316 }
19317
19318 double _MSVC2022_tmp1, _MSVC2022_tmp2;
19319 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
19320
19321 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
19322 {
19323 guys.spr(i)->dir=l_down;
19324 }
19325 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
19326 {
19327 guys.spr(i)->dir=left;
19328 }
19329 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
19330 {
19331 guys.spr(i)->dir=l_up;
19332 }
19333 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
19334 {
19335 guys.spr(i)->dir=up;
19336 }
19337 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
19338 {
19339 guys.spr(i)->dir=r_up;
19340 }
19341 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
19342 {
19343 guys.spr(i)->dir=right;
19344 }
19345 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
19346 {
19347 guys.spr(i)->dir=r_down;
19348 }
19349 else
19350 {
19351 guys.spr(i)->dir=down;
19352 }
19353
19354 guys.spr(i)->x += x;
19355 guys.spr(i)->y += y;
19356 }
19357 }
19358
19359 adjusted=true;
19360 return enemy::animate(index);
19361 }
19362
19363 void ePatraBS::draw(BITMAP *dest)
19364 {
19365 tile=o_tile;
19366
19367 if(get_bit(quest_rules,qr_NEWENEMYTILES))
19368 {
19369 double _MSVC2022_tmp1, _MSVC2022_tmp2;
19370 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
19371
19372 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
19373 {
19374 lookat=l_down;
19375 }
19376 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
19377 {
19378 lookat=down;
19379 }
19380 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
19381 {
19382 lookat=r_down;
19383 }
19384 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
19385 {
19386 lookat=right;
19387 }
19388 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
19389 {
19390 lookat=r_up;
19391 }
19392 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
19393 {
19394 lookat=up;
19395 }
19396 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
19397 {
19398 lookat=l_up;
19399 }
19400 else
19401 {
19402 lookat=left;
19403 }
19404
19405 switch(lookat) //directions get screwed up after 8. *shrug*
19406 {
19407 case up: //u
19408 flip=0;
19409 break;
19410
19411 case down: //d
19412 flip=0;
19413 tile+=8;
19414 break;
19415
19416 case left: //l
19417 flip=0;
19418 tile+=40;
19419 break;
19420
19421 case right: //r
19422 flip=0;
19423 tile+=48;
19424 break;
19425
19426 case l_up: //ul
19427 flip=0;
19428 tile+=80;
19429 break;
19430
19431 case r_up: //ur
19432 flip=0;
19433 tile+=88;
19434 break;
19435
19436 case l_down: //dl
19437 flip=0;
19438 tile+=120;
19439 break;
19440
19441 case r_down: //dr
19442 flip=0;
19443 tile+=128;
19444 break;
19445 }
19446
19447 tile+=(2*(clk&3));
19448 xofs-=8;
19449 yofs-=8;
19450 drawblock(dest,15);
19451 xofs+=8;
19452 yofs+=8;
19453 }
19454 else
19455 {
19456 flip=(clk&1);
19457 xofs-=8;
19458 yofs-=8;
19459 enemy::draw(dest);
19460 xofs+=16;
19461 enemy::draw(dest);
19462 yofs+=16;
19463 enemy::draw(dest);
19464 xofs-=16;
19465 enemy::draw(dest);
19466 xofs+=8;
19467 yofs-=8;
19468 }
19469 }
19470
19471 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
19472 {
19473 int32_t ret = enemy::defend(wpnId, power, edef);
19474
19475 if(ret < 0 && (flycnt||flycnt2))
19476 return 0;
19477
19478 return ret;
19479 }
19480
19481 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
19482 {
19483 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
19484
19485 if(ret < 0 && (flycnt||flycnt2))
19486 return 0;
19487
19488 return ret;
19489 }
19490
19491 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
19492 {
19493 //cs=csBOSS;
19494 item_set=0;
19495 misc=clk;
19496 clk = -((misc*21)>>1)-1;
19497 clk4 = 0;
19498 clk5 = 0;
19499 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
19500 int32_t prntSIZEflags = prntenemy->SIZEflags;
19501 if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
19502 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
19503 // al_trace("Enemy txsz:%i\n", txsz);
19504 if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
19505 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
19506 else hxsz=16;
19507 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
19508 else hysz=16;
19509 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
19510 if ( (prntSIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
19511 if ( (prntSIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
19512 else hyofs=2;
19513 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
19514 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
19515 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
19516 {
19517 yofs = (int32_t)prntenemy->yofs;
19518 }
19519 else yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
19520 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
19521
19522 bgsfx=-1;
19523 mainguy=count_enemy=false;
19524 deadsfx = WAV_EDEAD;
19525 hitsfx = WAV_EHIT;
19526 flags &= ~guy_neverret;
19527 isCore = false;
19528 }
19529
19530 bool esPatraBS::animate(int32_t index)
19531 {
19532 if(switch_hooked) return enemy::animate(index);
19533 if(dying)
19534 return Dead(index);
19535
19536 return enemy::animate(index);
19537 }
19538
19539 void esPatraBS::draw(BITMAP *dest)
19540 {
19541 tile=o_tile;
19542
19543 if(get_bit(quest_rules,qr_NEWENEMYTILES))
19544 {
19545 switch(dir) //directions get screwed up after 8. *shrug*
19546 {
19547 case up: //u
19548 flip=0;
19549 break;
19550
19551 case down: //d
19552 flip=0;
19553 tile+=4;
19554 break;
19555
19556 case left: //l
19557 flip=0;
19558 tile+=8;
19559 break;
19560
19561 case right: //r
19562 flip=0;
19563 tile+=12;
19564 break;
19565
19566 case l_up: //ul
19567 flip=0;
19568 tile+=20;
19569 break;
19570
19571 case r_up: //ur
19572 flip=0;
19573 tile+=24;
19574 break;
19575
19576 case l_down: //dl
19577 flip=0;
19578 tile+=28;
19579 break;
19580
19581 case r_down: //dr
19582 flip=0;
19583 tile+=32;
19584 break;
19585 }
19586
19587 tile += ((clk&6)>>1);
19588 }
19589 else
19590 {
19591 tile += (clk&4)?1:0;
19592 }
19593
19594 if(clk>=0)
19595 enemy::draw(dest);
19596 }
19597
19598
19599 /**********************************/
19600 /********** Misc Code ***********/
19601 /**********************************/
19602
19603 30793 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
19604 {
19605
4/6
✓ Branch 0 taken 4124 times.
✓ Branch 1 taken 26669 times.
✓ Branch 2 taken 4124 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4124 times.
✗ Branch 5 not taken.
30793 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
19606
4/8
✓ Branch 0 taken 30793 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30793 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30793 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 30793 times.
✗ Branch 7 not taken.
30793 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
19607
1/2
✓ Branch 0 taken 30793 times.
✗ Branch 1 not taken.
30793 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19608 30793 }
19609
19610 21166 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon)
19611 {
19612 // Kludge
19613
4/8
✓ Branch 0 taken 21166 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21166 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21166 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 21166 times.
✗ Branch 7 not taken.
21166 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
19614 21166 int32_t ret= ((enemy*)guys.spr(index))->takehit(w);
19615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21166 times.
21166 delete w;
19616 21166 return ret;
19617 }
19618
19619 1966 void enemy_scored(int32_t index)
19620 {
19621 1966 ((enemy*)guys.spr(index))->scored=true;
19622 1966 }
19623
19624 725 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy)
19625 {
19626
7/12
✓ Branch 0 taken 725 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 725 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 725 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 725 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 112 times.
✓ Branch 9 taken 613 times.
✓ Branch 10 taken 725 times.
✗ Branch 11 not taken.
725 guy *g = new guy((zfix)x,(zfix)(y+(isdungeon()?1:0)),id,get_bit(quest_rules,qr_NOGUYPOOF)?0:clk,mainguy);
19627 725 guys.add(g);
19628 725 }
19629
19630 484 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
19631 {
19632
5/10
✓ Branch 0 taken 484 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 484 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 484 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 484 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 484 times.
✗ Branch 9 not taken.
484 item *i = new item(zfix(x), zfix(y - get_bit(quest_rules, qr_NOITEMOFFSET)), zfix(0), id, pickup, 0);
19633 484 items.add(i);
19634 484 }
19635
19636 30 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
19637 {
19638
6/12
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 30 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 30 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 30 times.
✗ Branch 11 not taken.
30 item *i = new item((zfix)x,(zfix)y-(get_bit(quest_rules, qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
19639 30 items.add(i);
19640 30 }
19641
19642 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
19643 {
19644 item *i = new item((zfix)x,(zfix)y-(get_bit(quest_rules, qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
19645 items.add(i);
19646 }
19647
19648 43 void kill_em_all()
19649 {
19650
2/2
✓ Branch 0 taken 209 times.
✓ Branch 1 taken 43 times.
252 for(int32_t i=0; i<guys.Count(); i++)
19651 {
19652 209 enemy *e = ((enemy*)guys.spr(i));
19653
19654
3/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 184 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
209 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
19655
19656 184 e->kickbucket();
19657 184 }
19658 43 }
19659
19660 bool can_kill_em_all()
19661 {
19662 for(int32_t i=0; i<guys.Count(); i++)
19663 {
19664 enemy *e = ((enemy*)guys.spr(i));
19665
19666 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
19667 if(e->superman) continue;
19668 return true;
19669 }
19670 return false;
19671 }
19672
19673 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
19674 // For Hero's hit detection. Don't count them if they are stunned or are guys.
19675 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
19676 {
19677 for(int32_t i=0; i<guys.Count(); i++)
19678 {
19679 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
19680 {
19681 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_bit(quest_rules, qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
19682 &&(((enemy*)guys.spr(i))->d->family != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
19683 {
19684 return i;
19685 }
19686 }
19687 }
19688
19689 return -1;
19690 }
19691
19692 2568662 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
19693 {
19694
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2568662 times.
✓ Branch 2 taken 9575556 times.
✓ Branch 3 taken 2561897 times.
12137453 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
19695 {
19696
2/2
✓ Branch 0 taken 6765 times.
✓ Branch 1 taken 9568791 times.
9575556 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
19697 {
19698 6765 return i;
19699 }
19700 9568791 }
19701
19702 2561897 return -1;
19703 2568662 }
19704
19705 // For Hero's hit detection. Count them if they are dying.
19706 15824 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
19707 {
19708 15824 enemy *e = (enemy*)guys.spr(index);
19709
3/4
✓ Branch 0 taken 15824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9134 times.
✓ Branch 3 taken 6690 times.
15824 if(!e || e->hp > 0)
19710 9134 return -1;
19711
19712 6690 bool d = e->dying;
19713 6690 int32_t hc = e->hclk;
19714 6690 e->dying = false;
19715 6690 e->hclk = 0;
19716 6690 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
19717 6690 e->dying = d;
19718 6690 e->hclk = hc;
19719
19720
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 6644 times.
6690 return hit ? index : -1;
19721 15824 }
19722
19723 2809577 bool hasMainGuy()
19724 {
19725
2/2
✓ Branch 0 taken 4646469 times.
✓ Branch 1 taken 674696 times.
5321165 for(int32_t i=0; i<guys.Count(); i++)
19726 {
19727
2/2
✓ Branch 0 taken 2134881 times.
✓ Branch 1 taken 2511588 times.
4646469 if(((enemy*)guys.spr(i))->mainguy)
19728 {
19729 2134881 return true;
19730 }
19731 2511588 }
19732
19733 674696 return false;
19734 2809577 }
19735
19736 41 void EatHero(int32_t index)
19737 {
19738 41 ((eStalfos*)guys.spr(index))->eathero();
19739 41 }
19740
19741 3 void GrabHero(int32_t index)
19742 {
19743 3 ((eWallM*)guys.spr(index))->grabhero();
19744 3 }
19745
19746 292 bool CarryHero()
19747 {
19748
1/2
✓ Branch 0 taken 891 times.
✗ Branch 1 not taken.
891 for(int32_t i=0; i<guys.Count(); i++)
19749 {
19750
2/2
✓ Branch 0 taken 536 times.
✓ Branch 1 taken 355 times.
891 if(((guy*)(guys.spr(i)))->family==eeWALLM)
19751 {
19752
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 63 times.
355 if(((eWallM*)guys.spr(i))->hashero)
19753 {
19754 292 Hero.x=guys.spr(i)->x;
19755 292 Hero.y=guys.spr(i)->y;
19756 292 return ((eWallM*)guys.spr(i))->misc > 0;
19757 }
19758 63 }
19759
19760 // Like Likes currently can't carry Hero.
19761 /*
19762 if(((guy*)(guys.spr(i)))->family==eeLIKE)
19763 {
19764 if(((eLikeLike*)guys.spr(i))->hashero)
19765 {
19766 Hero.x=guys.spr(i)->x;
19767 Hero.y=guys.spr(i)->y;
19768 return (true);
19769 }
19770 }*/
19771 599 }
19772
19773 return false;
19774 292 }
19775
19776 // Move item with guy
19777 void movefairy(zfix &x,zfix &y,int32_t misc)
19778 {
19779 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
19780
19781 if(i!=-1)
19782 {
19783 x = guys.spr(i)->x;
19784 y = guys.spr(i)->y;
19785 }
19786 }
19787
19788 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
19789 void movefairy2(zfix x,zfix y,int32_t misc)
19790 {
19791 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
19792
19793 if(i!=-1)
19794 {
19795 guys.spr(i)->x = x;
19796 guys.spr(i)->y = y;
19797 }
19798 }// Move item with guy
19799
19800 20417 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
19801 {
19802 20417 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
19803
19804
1/2
✓ Branch 0 taken 20417 times.
✗ Branch 1 not taken.
20417 if(fairy)
19805 {
19806 20417 x = fairy->x;
19807 20417 y = fairy->y;
19808 20417 }
19809 20417 }
19810
19811 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
19812 void movefairynew2(zfix x,zfix y, item const &itemfairy)
19813 {
19814 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
19815
19816 if(fairy)
19817 {
19818 fairy->x = x;
19819 fairy->y = y;
19820 }
19821 }
19822
19823 void killfairy(int32_t misc)
19824 {
19825 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
19826 guys.del(i);
19827 }
19828
19829 int32_t getGuyIndex(const int32_t eid)
19830 {
19831 for(word i = 0; i < guys.Count(); i++)
19832 {
19833 if(guys.spr(i)->getUID() == eid)
19834 return i;
19835 }
19836
19837 return -1;
19838 }
19839
19840 void killfairynew(item const &itemfairy)
19841 {
19842 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
19843 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
19844 }
19845
19846 //Should probably change this to return an 'enemy*', null on failure -Em
19847 7034 int32_t addenemy(int32_t x,int32_t y,int32_t id,int32_t clk)
19848 {
19849 7034 return addenemy(x,y,0,id,clk);
19850 }
19851
19852 784 int32_t addchild(int32_t x,int32_t y,int32_t id,int32_t clk, int32_t parent_scriptUID)
19853 {
19854 784 return addchild(x,y,0,id,clk, parent_scriptUID);
19855 }
19856
19857 809 int32_t addchild(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, int32_t parent_scriptUID)
19858 {
19859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 809 times.
809 if(id <= 0) return 0;
19860
19861 809 int32_t ret = 0;
19862 809 sprite *e=NULL;
19863 809 al_trace("Adding child\n");
19864
19865
5/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 773 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
809 switch(guysbuf[id&0xFFF].family)
19866 {
19867 //Fixme: possible enemy memory leak. (minor)
19868 case eeWALK:
19869
3/6
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
16 e = new eStalfos((zfix)x,(zfix)y,id,clk);
19870 16 break;
19871
19872 case eeLEV:
19873 e = new eLeever((zfix)x,(zfix)y,id,clk);
19874 break;
19875
19876 case eeTEK:
19877 e = new eTektite((zfix)x,(zfix)y,id,clk);
19878 break;
19879
19880 case eePEAHAT:
19881 e = new ePeahat((zfix)x,(zfix)y,id,clk);
19882 break;
19883
19884 case eeZORA:
19885 e = new eZora((zfix)x,(zfix)y,id,clk);
19886 break;
19887
19888 case eeGHINI:
19889 e = new eGhini((zfix)x,(zfix)y,id,clk);
19890 break;
19891
19892 case eeKEESE:
19893
3/6
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 773 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 773 times.
✗ Branch 5 not taken.
773 e = new eKeese((zfix)x,(zfix)y,id,clk);
19894 773 break;
19895
19896 case eeWIZZ:
19897
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
19898 15 break;
19899
19900 case eePROJECTILE:
19901 e = new eProjectile((zfix)x,(zfix)y,id,clk);
19902 break;
19903
19904 case eeWALLM:
19905 e = new eWallM((zfix)x,(zfix)y,id,clk);
19906 break;
19907
19908 case eeAQUA:
19909 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
19910 break;
19911
19912 case eeMOLD:
19913 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
19914 break;
19915
19916 case eeMANHAN:
19917
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
19918 1 break;
19919
19920 case eeGLEEOK:
19921 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
19922 break;
19923
19924 case eeGHOMA:
19925 e = new eGohma((zfix)x,(zfix)y,id,clk);
19926 break;
19927
19928 case eeLANM:
19929 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)));
19930 break;
19931
19932 case eeGANON:
19933 e = new eGanon((zfix)x,(zfix)y,id,clk);
19934 break;
19935
19936 case eeFAIRY:
19937 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
19938 break;
19939
19940 case eeFIRE:
19941 e = new eFire((zfix)x,(zfix)y,id,clk);
19942 break;
19943
19944 case eeOTHER:
19945 e = new eOther((zfix)x,(zfix)y,id,clk);
19946 break;
19947
19948
19949 case eeSCRIPT01:
19950 case eeSCRIPT02:
19951 case eeSCRIPT03:
19952 case eeSCRIPT04:
19953 case eeSCRIPT05:
19954 case eeSCRIPT06:
19955 case eeSCRIPT07:
19956 case eeSCRIPT08:
19957 case eeSCRIPT09:
19958 case eeSCRIPT10:
19959 case eeSCRIPT11:
19960 case eeSCRIPT12:
19961 case eeSCRIPT13:
19962 case eeSCRIPT14:
19963 case eeSCRIPT15:
19964 case eeSCRIPT16:
19965 case eeSCRIPT17:
19966 case eeSCRIPT18:
19967 case eeSCRIPT19:
19968 case eeSCRIPT20:
19969 {
19970 if ( !get_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
19971 {
19972 e = new eScript((zfix)x,(zfix)y,id,clk);
19973 break;
19974 }
19975 else return 0;
19976 }
19977
19978 case eeFFRIENDLY01:
19979 case eeFFRIENDLY02:
19980 case eeFFRIENDLY03:
19981 case eeFFRIENDLY04:
19982 case eeFFRIENDLY05:
19983 case eeFFRIENDLY06:
19984 case eeFFRIENDLY07:
19985 case eeFFRIENDLY08:
19986 case eeFFRIENDLY09:
19987 case eeFFRIENDLY10:
19988 {
19989 if ( !get_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
19990 {
19991 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
19992 }
19993 else return 0;
19994
19995 }
19996
19997 case eeSPINTILE:
19998 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
19999 break;
20000
20001 // and these enemies use the misc10/misc2 value
20002 case eeROCK:
20003 {
20004 switch(guysbuf[id&0xFFF].misc10)
20005 {
20006 case 1:
20007 e = new eBoulder((zfix)x,(zfix)y,id,clk);
20008 break;
20009
20010 case 0:
20011 default:
20012 e = new eRock((zfix)x,(zfix)y,id,clk);
20013 break;
20014 }
20015
20016 break;
20017 }
20018
20019 case eeTRAP:
20020 {
20021 switch(guysbuf[id&0xFFF].misc2)
20022 {
20023 case 1:
20024 e = new eTrap2((zfix)x,(zfix)y,id,clk);
20025 break;
20026
20027 case 0:
20028 default:
20029 e = new eTrap((zfix)x,(zfix)y,id,clk);
20030 break;
20031 }
20032
20033 break;
20034 }
20035
20036 case eeDONGO:
20037 {
20038 switch(guysbuf[id&0xFFF].misc10)
20039 {
20040 case 1:
20041 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
20042 break;
20043
20044 case 0:
20045 default:
20046 e = new eDodongo((zfix)x,(zfix)y,id,clk);
20047 break;
20048 }
20049
20050 break;
20051 }
20052
20053 case eeDIG:
20054 {
20055
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].misc10)
20056 {
20057 case 1:
20058 e = new eLilDig((zfix)x,(zfix)y,id,clk);
20059 break;
20060
20061 4 case 0:
20062 default:
20063
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
20064 4 break;
20065 }
20066
20067 4 break;
20068 }
20069
20070 case eePATRA:
20071 {
20072 switch(guysbuf[id&0xFFF].misc10)
20073 {
20074 case 1:
20075 if (get_bit(quest_rules,qr_HARDCODED_BS_PATRA))
20076 {
20077 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
20078 break;
20079 }
20080 [[fallthrough]];
20081 case 0:
20082 default:
20083 e = new ePatra((zfix)x,(zfix)y,id,clk);
20084 break;
20085 }
20086
20087 break;
20088 }
20089
20090 case eeGUY:
20091 {
20092 switch(guysbuf[id&0xFFF].misc10)
20093 {
20094 case 1:
20095 e = new eTrigger((zfix)x,(zfix)y,id,clk);
20096 break;
20097
20098 case 0:
20099 default:
20100 e = new eNPC((zfix)x,(zfix)y,id,clk);
20101 break;
20102 }
20103
20104 break;
20105 }
20106
20107 case eeNONE:
20108 if(guysbuf[id&0xFFF].misc10 ==1)
20109 {
20110 e = new eTrigger((zfix)x,(zfix)y,id,clk);
20111 break;
20112 break;
20113 }
20114 [[fallthrough]];
20115 default:
20116
20117 return 0;
20118 }
20119
20120 809 ret++; // Made one enemy.
20121
20122
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 809 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
809 if(z && canfall(id))
20123 {
20124 e->z = (zfix)z;
20125 }
20126
20127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 809 times.
809 ((enemy*)e)->ceiling = (z && canfall(id));
20128 809 ((enemy*)e)->parent_script_UID = parent_scriptUID;
20129 //al_trace("Child Script UID: %d\n",((enemy*)e)->script_UID);
20130 //zprint2("Child Script UID: %d\n",((enemy*)e)->script_UID);
20131 //al_trace("Child's Parent UID: %d\n",((enemy*)e)->parent_script_UID);
20132 //zprint2("Child's Parent UID: %d\n",((enemy*)e)->parent_script_UID);
20133
20134
20135
1/2
✓ Branch 0 taken 809 times.
✗ Branch 1 not taken.
809 if(!guys.add(e))
20136 {
20137 return 0;
20138 }
20139
20140 // add segments of segmented enemies
20141 809 int32_t c=0;
20142
20143
2/6
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
809 switch(guysbuf[id&0xFFF].family)
20144 {
20145 case eeMOLD:
20146 {
20147 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
20148 id &= 0xFFF;
20149
20150 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].misc1)); i++)
20151 {
20152 //christ this is messy -DD
20153 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
20154
20155 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
20156 {
20157 al_trace("Moldorm segment %d could not be created!\n",i+1);
20158
20159 for(int32_t j=0; j<i+1; j++)
20160 guys.del(guys.Count()-1);
20161
20162 return 0;
20163 }
20164
20165 if(i>0)
20166 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
20167
20168 ret++;
20169 }
20170
20171 break;
20172 }
20173
20174 case eeLANM:
20175 {
20176 id &= 0xFFF;
20177 int32_t shft = guysbuf[id].misc2;
20178 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
20179
20180 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
20181 {
20182 al_trace("Lanmola segment 1 could not be created!\n");
20183 guys.del(guys.Count()-1);
20184 return 0;
20185 }
20186
20187 ret++;
20188
20189 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)); i++)
20190 {
20191 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
20192 {
20193 al_trace("Lanmola segment %d could not be created!\n",i+1);
20194
20195 for(int32_t j=0; j<i+1; j++)
20196 guys.del(guys.Count()-1);
20197
20198 return 0;
20199 }
20200
20201 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
20202 ret++;
20203 }
20204 }
20205 break;
20206
20207 case eeMANHAN:
20208 1 id &= 0xFFF;
20209
20210
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].misc2))?4:8); i++)
20211 {
20212
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
20213 {
20214 al_trace("Manhandla head %d could not be created!\n",i+1);
20215
20216 for(int32_t j=0; j<i+1; j++)
20217 {
20218 guys.del(guys.Count()-1);
20219 }
20220
20221 return 0;
20222 }
20223
20224 4 ret++;
20225 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].misc1;
20226 4 }
20227
20228 1 break;
20229
20230 case eeGLEEOK:
20231 {
20232 id &= 0xFFF;
20233
20234 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)); i++)
20235 {
20236 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
20237 {
20238 al_trace("Gleeok head %d could not be created!\n",i+1);
20239
20240 for(int32_t j=0; j<i+1; j++)
20241 {
20242 guys.del(guys.Count()-1);
20243 }
20244
20245 return false;
20246 }
20247
20248 c-=guysbuf[id].misc4;
20249 ret++;
20250 }
20251 }
20252 break;
20253
20254
20255 case eePATRA:
20256 {
20257 id &= 0xFFF;
20258 int32_t outeyes = 0;
20259
20260 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc1); i++)
20261 {
20262 if(!((guysbuf[id].misc10&&get_bit(quest_rules,qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
20263 {
20264 al_trace("Patra outer eye %d could not be created!\n",i+1);
20265
20266 for(int32_t j=0; j<i+1; j++)
20267 guys.del(guys.Count()-1);
20268
20269 return 0;
20270 }
20271 else
20272 outeyes++;
20273
20274 ret++;
20275 }
20276
20277 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc2); i++)
20278 {
20279 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
20280 {
20281 al_trace("Patra inner eye %d could not be created!\n",i+1);
20282
20283 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
20284 guys.del(guys.Count()-1);
20285
20286 return 0;
20287 }
20288
20289 ret++;
20290 }
20291
20292 break;
20293 }
20294 }
20295
20296 809 return ret;
20297 809 }
20298
20299 // Returns number of enemies/segments created
20300 20573 int32_t addenemy(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
20301 {
20302 //zprint2("addenemy id is: %d\n", (id&0xFFF));
20303 20573 int32_t realid = id&0xFFF;
20304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20573 times.
20573 if( realid > MAXGUYS )
20305 {
20306 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "addenemy()");
20307 return 0;
20308 }
20309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20573 times.
20573 if(id <= 0) return 0;
20310
20311 20573 int32_t ret = 0;
20312 20573 sprite *e=NULL;
20313
20314
25/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10431 times.
✓ Branch 4 taken 638 times.
✓ Branch 5 taken 1053 times.
✓ Branch 6 taken 369 times.
✓ Branch 7 taken 1086 times.
✓ Branch 8 taken 53 times.
✓ Branch 9 taken 2478 times.
✓ Branch 10 taken 1159 times.
✓ Branch 11 taken 1462 times.
✓ Branch 12 taken 285 times.
✓ Branch 13 taken 36 times.
✓ Branch 14 taken 29 times.
✓ Branch 15 taken 35 times.
✓ Branch 16 taken 43 times.
✓ Branch 17 taken 24 times.
✓ Branch 18 taken 70 times.
✓ Branch 19 taken 4 times.
✓ Branch 20 taken 198 times.
✓ Branch 21 taken 37 times.
✓ Branch 22 taken 294 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 154 times.
✓ Branch 25 taken 338 times.
✓ Branch 26 taken 80 times.
✓ Branch 27 taken 186 times.
✓ Branch 28 taken 31 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
20573 switch(guysbuf[id&0xFFF].family)
20315 {
20316 //Fixme: possible enemy memory leak. (minor)
20317 case eeWALK:
20318
3/6
✓ Branch 0 taken 10431 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10431 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10431 times.
✗ Branch 5 not taken.
10431 e = new eStalfos((zfix)x,(zfix)y,id,clk);
20319 10431 break;
20320
20321 case eeLEV:
20322
3/6
✓ Branch 0 taken 638 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 638 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 638 times.
✗ Branch 5 not taken.
638 e = new eLeever((zfix)x,(zfix)y,id,clk);
20323 638 break;
20324
20325 case eeTEK:
20326
3/6
✓ Branch 0 taken 1053 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1053 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1053 times.
✗ Branch 5 not taken.
1053 e = new eTektite((zfix)x,(zfix)y,id,clk);
20327 1053 break;
20328
20329 case eePEAHAT:
20330
3/6
✓ Branch 0 taken 369 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 369 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 369 times.
✗ Branch 5 not taken.
369 e = new ePeahat((zfix)x,(zfix)y,id,clk);
20331 369 break;
20332
20333 case eeZORA:
20334
3/6
✓ Branch 0 taken 1086 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1086 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1086 times.
✗ Branch 5 not taken.
1086 e = new eZora((zfix)x,(zfix)y,id,clk);
20335 1086 break;
20336
20337 case eeGHINI:
20338
3/6
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 53 times.
✗ Branch 5 not taken.
53 e = new eGhini((zfix)x,(zfix)y,id,clk);
20339 53 break;
20340
20341 case eeKEESE:
20342
3/6
✓ Branch 0 taken 2478 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2478 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2478 times.
✗ Branch 5 not taken.
2478 e = new eKeese((zfix)x,(zfix)y,id,clk);
20343 2478 break;
20344
20345 case eeWIZZ:
20346
3/6
✓ Branch 0 taken 1159 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1159 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1159 times.
✗ Branch 5 not taken.
1159 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
20347 1159 break;
20348
20349 case eePROJECTILE:
20350
3/6
✓ Branch 0 taken 1462 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1462 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1462 times.
✗ Branch 5 not taken.
1462 e = new eProjectile((zfix)x,(zfix)y,id,clk);
20351 1462 break;
20352
20353 case eeWALLM:
20354
3/6
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 285 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 285 times.
✗ Branch 5 not taken.
285 e = new eWallM((zfix)x,(zfix)y,id,clk);
20355 285 break;
20356
20357 case eeAQUA:
20358
3/6
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
36 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
20359 36 break;
20360
20361 case eeMOLD:
20362
6/12
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 29 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 29 times.
✓ Branch 10 taken 29 times.
✗ Branch 11 not taken.
29 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
20363 29 break;
20364
20365 case eeMANHAN:
20366
3/6
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 35 times.
✗ Branch 5 not taken.
35 e = new eManhandla((zfix)x,(zfix)y,id,clk);
20367 35 break;
20368
20369 case eeGLEEOK:
20370
6/12
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 43 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 43 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 43 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 43 times.
✓ Branch 10 taken 43 times.
✗ Branch 11 not taken.
43 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
20371 43 break;
20372
20373 case eeGHOMA:
20374
3/6
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
24 e = new eGohma((zfix)x,(zfix)y,id,clk);
20375 24 break;
20376
20377 case eeLANM:
20378
6/12
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 70 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 70 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 70 times.
✓ Branch 10 taken 70 times.
✗ Branch 11 not taken.
70 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)));
20379 70 break;
20380
20381 case eeGANON:
20382
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eGanon((zfix)x,(zfix)y,id,clk);
20383 4 break;
20384
20385 case eeFAIRY:
20386
3/6
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 198 times.
✗ Branch 5 not taken.
198 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
20387 198 break;
20388
20389 case eeFIRE:
20390
3/6
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 37 times.
✗ Branch 5 not taken.
37 e = new eFire((zfix)x,(zfix)y,id,clk);
20391 37 break;
20392
20393 case eeOTHER:
20394
3/6
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 294 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 294 times.
✗ Branch 5 not taken.
294 e = new eOther((zfix)x,(zfix)y,id,clk);
20395 294 break;
20396
20397
20398 case eeSCRIPT01:
20399 case eeSCRIPT02:
20400 case eeSCRIPT03:
20401 case eeSCRIPT04:
20402 case eeSCRIPT05:
20403 case eeSCRIPT06:
20404 case eeSCRIPT07:
20405 case eeSCRIPT08:
20406 case eeSCRIPT09:
20407 case eeSCRIPT10:
20408 case eeSCRIPT11:
20409 case eeSCRIPT12:
20410 case eeSCRIPT13:
20411 case eeSCRIPT14:
20412 case eeSCRIPT15:
20413 case eeSCRIPT16:
20414 case eeSCRIPT17:
20415 case eeSCRIPT18:
20416 case eeSCRIPT19:
20417 case eeSCRIPT20:
20418 {
20419 if ( !get_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
20420 {
20421 e = new eScript((zfix)x,(zfix)y,id,clk);
20422 break;
20423 }
20424 else return 0;
20425 }
20426
20427 case eeFFRIENDLY01:
20428 case eeFFRIENDLY02:
20429 case eeFFRIENDLY03:
20430 case eeFFRIENDLY04:
20431 case eeFFRIENDLY05:
20432 case eeFFRIENDLY06:
20433 case eeFFRIENDLY07:
20434 case eeFFRIENDLY08:
20435 case eeFFRIENDLY09:
20436 case eeFFRIENDLY10:
20437 {
20438 if ( !get_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
20439 {
20440 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
20441 }
20442 else return 0;
20443
20444 }
20445
20446 case eeSPINTILE:
20447 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
20448 break;
20449
20450 // and these enemies use the misc10/misc2 value
20451 case eeROCK:
20452 {
20453
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 154 times.
154 switch(guysbuf[id&0xFFF].misc10)
20454 {
20455 case 1:
20456 e = new eBoulder((zfix)x,(zfix)y,id,clk);
20457 break;
20458
20459 154 case 0:
20460 default:
20461
3/6
✓ Branch 0 taken 154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 154 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 154 times.
✗ Branch 5 not taken.
154 e = new eRock((zfix)x,(zfix)y,id,clk);
20462 154 break;
20463 }
20464
20465 154 break;
20466 }
20467
20468 case eeTRAP:
20469 {
20470
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 334 times.
338 switch(guysbuf[id&0xFFF].misc2)
20471 {
20472 case 1:
20473
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eTrap2((zfix)x,(zfix)y,id,clk);
20474 4 break;
20475
20476 334 case 0:
20477 default:
20478
3/6
✓ Branch 0 taken 334 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 334 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 334 times.
✗ Branch 5 not taken.
334 e = new eTrap((zfix)x,(zfix)y,id,clk);
20479 334 break;
20480 }
20481
20482 338 break;
20483 }
20484
20485 case eeDONGO:
20486 {
20487
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
80 switch(guysbuf[id&0xFFF].misc10)
20488 {
20489 case 1:
20490 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
20491 break;
20492
20493 80 case 0:
20494 default:
20495
3/6
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 80 times.
✗ Branch 5 not taken.
80 e = new eDodongo((zfix)x,(zfix)y,id,clk);
20496 80 break;
20497 }
20498
20499 80 break;
20500 }
20501
20502 case eeDIG:
20503 {
20504
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 155 times.
✓ Branch 2 taken 31 times.
186 switch(guysbuf[id&0xFFF].misc10)
20505 {
20506 case 1:
20507
3/6
✓ Branch 0 taken 155 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 155 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 155 times.
✗ Branch 5 not taken.
155 e = new eLilDig((zfix)x,(zfix)y,id,clk);
20508 155 break;
20509
20510 31 case 0:
20511 default:
20512
3/6
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 31 times.
✗ Branch 5 not taken.
31 e = new eBigDig((zfix)x,(zfix)y,id,clk);
20513 31 break;
20514 }
20515
20516 186 break;
20517 }
20518
20519 case eePATRA:
20520 {
20521
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
31 switch(guysbuf[id&0xFFF].misc10)
20522 {
20523 case 1:
20524 if (get_bit(quest_rules,qr_HARDCODED_BS_PATRA))
20525 {
20526 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
20527 break;
20528 }
20529 [[fallthrough]];
20530 31 case 0:
20531 default:
20532
3/6
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 31 times.
✗ Branch 5 not taken.
31 e = new ePatra((zfix)x,(zfix)y,id,clk);
20533 31 break;
20534 }
20535
20536 31 break;
20537 }
20538
20539 case eeGUY:
20540 {
20541 switch(guysbuf[id&0xFFF].misc10)
20542 {
20543 case 1:
20544 e = new eTrigger((zfix)x,(zfix)y,id,clk);
20545 break;
20546
20547 case 0:
20548 default:
20549 e = new eNPC((zfix)x,(zfix)y,id,clk);
20550 break;
20551 }
20552
20553 break;
20554 }
20555
20556 case eeNONE:
20557 if(guysbuf[id&0xFFF].misc10 ==1)
20558 {
20559 e = new eTrigger((zfix)x,(zfix)y,id,clk);
20560 break;
20561 break;
20562 }
20563 [[fallthrough]];
20564 default:
20565
20566 return 0;
20567 }
20568
20569 20573 ret++; // Made one enemy.
20570
20571
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20573 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20573 if(z && canfall(id))
20572 {
20573 e->z = (zfix)z;
20574 }
20575
20576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20573 times.
20573 ((enemy*)e)->ceiling = (z && canfall(id));
20577
20578
1/2
✓ Branch 0 taken 20573 times.
✗ Branch 1 not taken.
20573 if(!guys.add(e))
20579 {
20580 return 0;
20581 }
20582
20583 // add segments of segmented enemies
20584 20573 int32_t c=0;
20585
20586
6/6
✓ Branch 0 taken 20365 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 70 times.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 43 times.
✓ Branch 5 taken 31 times.
20573 switch(guysbuf[id&0xFFF].family)
20587 {
20588 case eeMOLD:
20589 {
20590 29 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
20591 29 id &= 0xFFF;
20592
20593
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 234 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 234 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 234 times.
✓ Branch 6 taken 205 times.
✓ Branch 7 taken 29 times.
234 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].misc1)); i++)
20594 {
20595 //christ this is messy -DD
20596 205 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
20597
20598
4/8
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 205 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 205 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 205 times.
✗ Branch 7 not taken.
205 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
20599 {
20600 al_trace("Moldorm segment %d could not be created!\n",i+1);
20601
20602 for(int32_t j=0; j<i+1; j++)
20603 guys.del(guys.Count()-1);
20604
20605 return 0;
20606 }
20607
20608
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 176 times.
205 if(i>0)
20609 176 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
20610
20611 205 ret++;
20612 205 }
20613
20614 29 break;
20615 }
20616
20617 case eeLANM:
20618 {
20619 70 id &= 0xFFF;
20620 70 int32_t shft = guysbuf[id].misc2;
20621 70 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
20622
20623
4/8
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 70 times.
✗ Branch 7 not taken.
70 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
20624 {
20625 al_trace("Lanmola segment 1 could not be created!\n");
20626 guys.del(guys.Count()-1);
20627 return 0;
20628 }
20629
20630 70 ret++;
20631
20632
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 405 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 405 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 405 times.
✓ Branch 6 taken 335 times.
✓ Branch 7 taken 70 times.
405 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)); i++)
20633 {
20634
4/8
✓ Branch 0 taken 335 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 335 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 335 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 335 times.
✗ Branch 7 not taken.
335 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
20635 {
20636 al_trace("Lanmola segment %d could not be created!\n",i+1);
20637
20638 for(int32_t j=0; j<i+1; j++)
20639 guys.del(guys.Count()-1);
20640
20641 return 0;
20642 }
20643
20644 335 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
20645 335 ret++;
20646 335 }
20647 }
20648 70 break;
20649
20650 case eeMANHAN:
20651 35 id &= 0xFFF;
20652
20653
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 35 times.
191 for(int32_t i=0; i<((!(guysbuf[id].misc2))?4:8); i++)
20654 {
20655
4/8
✓ Branch 0 taken 156 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 156 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 156 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 156 times.
✗ Branch 7 not taken.
156 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
20656 {
20657 al_trace("Manhandla head %d could not be created!\n",i+1);
20658
20659 for(int32_t j=0; j<i+1; j++)
20660 {
20661 guys.del(guys.Count()-1);
20662 }
20663
20664 return 0;
20665 }
20666
20667 156 ret++;
20668 156 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].misc1;
20669 156 }
20670
20671 35 break;
20672
20673 case eeGLEEOK:
20674 {
20675 43 id &= 0xFFF;
20676
20677
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 176 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 176 times.
✓ Branch 6 taken 133 times.
✓ Branch 7 taken 43 times.
176 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)); i++)
20678 {
20679
4/8
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 133 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 133 times.
✗ Branch 7 not taken.
133 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
20680 {
20681 al_trace("Gleeok head %d could not be created!\n",i+1);
20682
20683 for(int32_t j=0; j<i+1; j++)
20684 {
20685 guys.del(guys.Count()-1);
20686 }
20687
20688 return false;
20689 }
20690
20691 133 c-=guysbuf[id].misc4;
20692 133 ret++;
20693 133 }
20694 }
20695 43 break;
20696
20697
20698 case eePATRA:
20699 {
20700 31 id &= 0xFFF;
20701 31 int32_t outeyes = 0;
20702
20703
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 279 times.
✓ Branch 2 taken 248 times.
✓ Branch 3 taken 31 times.
279 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc1); i++)
20704 {
20705
5/22
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 248 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 248 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 248 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 248 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
248 if(!((guysbuf[id].misc10&&get_bit(quest_rules,qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
20706 {
20707 al_trace("Patra outer eye %d could not be created!\n",i+1);
20708
20709 for(int32_t j=0; j<i+1; j++)
20710 guys.del(guys.Count()-1);
20711
20712 return 0;
20713 }
20714 else
20715 248 outeyes++;
20716
20717 248 ret++;
20718 248 }
20719
20720
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 31 times.
71 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc2); i++)
20721 {
20722
4/8
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 40 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 40 times.
✗ Branch 7 not taken.
40 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
20723 {
20724 al_trace("Patra inner eye %d could not be created!\n",i+1);
20725
20726 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
20727 guys.del(guys.Count()-1);
20728
20729 return 0;
20730 }
20731
20732 40 ret++;
20733 40 }
20734
20735 31 break;
20736 }
20737 }
20738
20739 20573 return ret;
20740 20573 }
20741
20742 139118 bool isjumper(int32_t id)
20743 {
20744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139118 times.
139118 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20745 {
20746 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isjumper()");
20747 return false;
20748 }
20749
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 101505 times.
✓ Branch 2 taken 37613 times.
139118 switch(guysbuf[id&0xFFF].family)
20750 {
20751 case eeROCK:
20752 case eeTEK:
20753 return true;
20754
20755 case eeWALK:
20756
2/4
✓ Branch 0 taken 37613 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37613 times.
37613 if(guysbuf[id&0xFFF].misc9==e9tVIRE || guysbuf[id&0xFFF].misc9==e9tPOLSVOICE) return true;
20757 37613 }
20758
20759 139118 return false;
20760 139118 }
20761
20762
20763 64333 bool isfixedtogrid(int32_t id)
20764 {
20765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64333 times.
64333 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20766 {
20767 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isfixedtogrid()");
20768 return false;
20769 }
20770
1/2
✓ Branch 0 taken 64333 times.
✗ Branch 1 not taken.
64333 switch(guysbuf[id&0xFFF].family)
20771 {
20772 case eeWALK:
20773 case eeLEV:
20774 case eeZORA:
20775 case eeDONGO:
20776 case eeGANON:
20777 case eeROCK:
20778 case eeGLEEOK:
20779 case eeAQUA:
20780 case eeLANM:
20781 return true;
20782 }
20783
20784 64333 return false;
20785 64333 }
20786
20787 // Can't fall, can have Z value.
20788 16721449 bool isflier(int32_t id)
20789 {
20790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16721449 times.
16721449 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20791 {
20792 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isflier()");
20793 return false;
20794 }
20795
2/2
✓ Branch 0 taken 14959398 times.
✓ Branch 1 taken 1762051 times.
16721449 switch(guysbuf[id&0xFFF].family) //id&0x0FFF)
20796 {
20797 case eePEAHAT:
20798 case eeKEESE:
20799 case eePATRA:
20800 case eeFAIRY:
20801 case eeGHINI:
20802
20803 // Could theoretically have their Z set by a script
20804 case eeFIRE:
20805 1762051 return true;
20806 break;
20807 }
20808
20809 14959398 return false;
20810 16721449 }
20811
20812 // Can't have Z position
20813 286742 bool never_in_air(int32_t id)
20814 {
20815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 286742 times.
286742 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20816 {
20817 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "never_in_air()");
20818 return false;
20819 }
20820
1/2
✓ Branch 0 taken 286742 times.
✗ Branch 1 not taken.
286742 switch(guysbuf[id&0xFFF].family)
20821 {
20822 case eeMANHAN:
20823 case eeMOLD:
20824 case eeLANM:
20825 case eeGLEEOK:
20826 case eeZORA:
20827 case eeLEV:
20828 case eeAQUA:
20829 case eeROCK:
20830 case eeGANON:
20831 case eeTRAP:
20832 case eePROJECTILE:
20833 case eeSPINTILE:
20834 return true;
20835 }
20836
20837 286742 return false;
20838 286742 }
20839
20840 154439 bool canfall(int32_t id)
20841 {
20842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154439 times.
154439 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20843 {
20844 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "canfall()");
20845 return false;
20846 }
20847
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 154423 times.
✓ Branch 2 taken 16 times.
154439 switch(guysbuf[id&0xFFF].family)
20848 {
20849 case eeGUY:
20850 {
20851
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(id < eOCTO1S)
20852 16 return false;
20853
20854 switch(guysbuf[id&0xFFF].misc10)
20855 {
20856 case 1:
20857 case 2:
20858 return true;
20859
20860 case 0:
20861 case 3:
20862 default:
20863 return false;
20864 }
20865
20866 case eeGHOMA:
20867 case eeDIG:
20868 return false;
20869 }
20870 }
20871
20872
20873
3/4
✓ Branch 0 taken 154423 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15305 times.
✓ Branch 3 taken 139118 times.
154423 return !never_in_air(id) && !isflier(id) && !isjumper(id);
20874 154439 }
20875
20876 14089148 bool enemy::enemycanfall(int32_t id, bool checkgrav)
20877 {
20878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14089148 times.
14089148 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20879 {
20880 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "enemycanfall()");
20881 return false;
20882 }
20883 //Z_scripterrlog("canfall family is %d:\n", family);
20884 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & FLAG_OBEYS_GRAV ? "true" : "false");
20885 //if ( family == eeFIRE && id >= eSTART )
20886 //{
20887 // Z_scripterrlog("eeFire\n");
20888 // return moveflags & FLAG_OBEYS_GRAV; //'Other' enemy class, used by scripts. -Z
20889 //}
20890
20891 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
20892
20893
3/3
✓ Branch 0 taken 117383 times.
✓ Branch 1 taken 13696400 times.
✓ Branch 2 taken 275365 times.
14089148 switch(guysbuf[id&0xFFF].family)
20894 {
20895 case eeGUY:
20896 {
20897
1/2
✓ Branch 0 taken 275365 times.
✗ Branch 1 not taken.
275365 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
20898 275365 return false;
20899
20900 switch(guysbuf[id&0xFFF].misc10) //I'm unsure what these specify off-hand. Needs better comments. -Z
20901 {
20902 case 1:
20903 case 2:
20904 return true;
20905
20906 case 0:
20907 case 3:
20908 default:
20909 return false;
20910 }
20911
20912 case eeGHOMA:
20913 case eeDIG:
20914 117383 return false;
20915 }
20916 }
20917
20918
2/2
✓ Branch 0 taken 10977733 times.
✓ Branch 1 taken 2718667 times.
13696400 if(!checkgrav) return true;
20919 10977733 return (moveflags & FLAG_OBEYS_GRAV);
20920
20921 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
20922 // {
20923 // if ( moveflags & FLAG_OBEYS_GRAV ) return true;
20924 // else return false;
20925 // }
20926 // else
20927 // {
20928 // return (moveflags & FLAG_OBEYS_GRAV);
20929 // }
20930 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
20931 14089148 }
20932
20933 318 void addfires()
20934 {
20935
2/2
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 121 times.
318 if(!get_bit(quest_rules,qr_NOGUYFIRES))
20936 {
20937 197 int32_t bs = get_bit(quest_rules,qr_BSZELDA);
20938 197 addguy(bs? 64: 72,64,gFIRE,-17,false);
20939 197 addguy(bs?176:168,64,gFIRE,-18,false);
20940 197 }
20941 318 }
20942
20943 5142 void loadguys()
20944 {
20945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5142 times.
5142 if(loaded_guys)
20946 return;
20947
20948 5142 loaded_guys=true;
20949
20950 5142 byte Guy=0;
20951 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
20952 // Else use mITEM and ipONETIME
20953 5142 int32_t mf = (currscr>=128) ? mSPECIALITEM : mITEM;
20954 5142 int32_t onetime = (currscr>=128) ? ipONETIME2 : ipONETIME;
20955
20956 5142 repaircharge=0;
20957 5142 adjustmagic=false;
20958 5142 learnslash=false;
20959
20960
2/2
✓ Branch 0 taken 15426 times.
✓ Branch 1 taken 5142 times.
20568 for(int32_t i=0; i<3; i++)
20961 {
20962 15426 prices[i]=0;
20963 15426 }
20964
20965 5142 hasitem=0;
20966
20967
4/4
✓ Branch 0 taken 455 times.
✓ Branch 1 taken 4687 times.
✓ Branch 2 taken 254 times.
✓ Branch 3 taken 201 times.
5142 if(currscr>=128 && DMaps[currdmap].flags&dmfGUYCAVES)
20968 {
20969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 201 times.
201 if(DMaps[currdmap].flags&dmfCAVES)
20970 {
20971 201 Guy=tmpscr[1].guy;
20972 201 }
20973 201 }
20974 else
20975 {
20976 4941 Guy=tmpscr->guy;
20977
20978
4/4
✓ Branch 0 taken 4687 times.
✓ Branch 1 taken 254 times.
✓ Branch 2 taken 3306 times.
✓ Branch 3 taken 1381 times.
4941 if(currscr < 0x80 && (DMaps[currdmap].flags&dmfVIEWMAP))
20979 1381 game->maps[(currmap*MAPSCRSNORMAL)+currscr] |= mVISITED; // mark as visited
20980 }
20981
20982 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
20983
4/4
✓ Branch 0 taken 1553 times.
✓ Branch 1 taken 3589 times.
✓ Branch 2 taken 1222 times.
✓ Branch 3 taken 331 times.
5142 if(Guy && ((currscr>=128) == !!(DMaps[currdmap].flags&dmfGUYCAVES)))
20984 {
20985
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 327 times.
331 if(tmpscr->room==rZELDA)
20986 {
20987 4 addguy(120,72,Guy,-15,true);
20988 4 guys.spr(0)->hxofs=1000;
20989 4 addenemy(128,96,eFIRE,-15);
20990 4 addenemy(112,96,eFIRE,-15);
20991 4 addenemy(96,120,eFIRE,-15);
20992 4 addenemy(144,120,eFIRE,-15);
20993 4 return;
20994 }
20995
20996
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 318 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
327 if(Guy!=gFAIRY || !get_bit(quest_rules,qr_NOFAIRYGUYFIRES))
20997 318 addfires();
20998
20999
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 201 times.
327 if(currscr>=128)
21000
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
203 if(getmapflag() && !(tmpscr->flags9&fBELOWRETURN))
21001 2 Guy=0;
21002
21003
3/6
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 261 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 13 times.
327 switch(tmpscr->room)
21004 {
21005 case rSP_ITEM:
21006 case rGRUMBLE:
21007 case rBOMBS:
21008 case rARROWS:
21009 case rSWINDLE:
21010 case rMUPGRADE:
21011 case rLEARNSLASH:
21012 case rTAKEONE:
21013
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 20 times.
✓ Branch 4 taken 53 times.
✓ Branch 5 taken 20 times.
✓ Branch 6 taken 20 times.
✓ Branch 7 taken 33 times.
53 if((get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)
21014 20 Guy=0;
21015
21016 93 break;
21017
21018 case rREPAIR:
21019 if (get_bit(quest_rules, qr_OLD_DOORREPAIR)) break;
21020 if((get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)
21021 Guy=0;
21022
21023 break;
21024 case rRP_HC:
21025 if (get_bit(quest_rules, qr_OLD_POTION_OR_HC)) break;
21026 if((get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)
21027 Guy=0;
21028
21029 break;
21030 case rMONEY:
21031 if (get_bit(quest_rules, qr_OLD_SECRETMONEY)) break;
21032 if((get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)
21033 Guy=0;
21034
21035 break;
21036
21037 case rTRIFORCE:
21038 {
21039 13 int32_t tc = TriforceCount();
21040
21041
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 3 times.
13 if(get_bit(quest_rules,qr_4TRI))
21042 {
21043
1/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if((get_bit(quest_rules,qr_3TRI) && tc>=3) || tc>=4)
21044 3 Guy=0;
21045 3 }
21046 else
21047 {
21048
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
10 if((get_bit(quest_rules,qr_3TRI) && tc>=6) || tc>=8)
21049 10 Guy=0;
21050 }
21051 }
21052 13 break;
21053 }
21054
21055
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 292 times.
327 if(Guy)
21056 {
21057
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 283 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
292 if(Guy!=gFAIRY || !get_bit(quest_rules,qr_NOFAIRYGUYFIRES))
21058 283 blockpath=true;
21059
21060
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 93 times.
292 if(currscr<128)
21061 93 sfx(WAV_SCALE);
21062
21063
3/4
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 199 times.
292 addguy(120,64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true);
21064 292 Hero.Freeze();
21065 292 }
21066 327 }
21067
2/2
✓ Branch 0 taken 4776 times.
✓ Branch 1 taken 35 times.
4811 else if(Guy==gFAIRY) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
21068 {
21069 35 sfx(WAV_SCALE);
21070 35 addguy(120,62,gFAIRY,-14,false);
21071 35 }
21072
21073 5138 loaditem();
21074
21075 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
21076 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
21077
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 5134 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 3 times.
5138 if(tmpscr->room==r10RUPIES && !getmapflag(mf))
21078 {
21079 //setmapflag();
21080
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 3 times.
33 for(int32_t i=0; i<10; i++)
21081 30 additem(ten_rupies_x[i],ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
21082 3 }
21083 5142 }
21084
21085 5142 void loaditem()
21086 {
21087 5142 byte Item = 0;
21088
21089
2/2
✓ Branch 0 taken 4687 times.
✓ Branch 1 taken 455 times.
5142 if(currscr<128)
21090 {
21091 4687 Item=tmpscr->item;
21092
21093
4/4
✓ Branch 0 taken 251 times.
✓ Branch 1 taken 4436 times.
✓ Branch 2 taken 4194 times.
✓ Branch 3 taken 493 times.
4687 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
21094 {
21095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 493 times.
493 if(tmpscr->flags8&fSECRETITEM)
21096 hasitem=8;
21097
2/2
✓ Branch 0 taken 347 times.
✓ Branch 1 taken 146 times.
493 else if(tmpscr->flags&fITEM)
21098 347 hasitem=1;
21099
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 131 times.
146 else if(tmpscr->enemyflags&efCARRYITEM)
21100 15 hasitem=4; // Will be set to 2 by roaming_item
21101 else
21102
2/4
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 131 times.
✗ Branch 3 not taken.
262 items.add(new item((zfix)tmpscr->itemx,
21103
7/14
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 129 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 131 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 131 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 131 times.
✗ Branch 13 not taken.
131 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_bit(quest_rules, qr_NOITEMOFFSET)?0:1),
21104
6/10
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 129 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 129 times.
✗ Branch 9 not taken.
131 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
21105
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 100 times.
131 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
21106 131 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
21107 493 }
21108 4687 }
21109
2/2
✓ Branch 0 taken 201 times.
✓ Branch 1 taken 254 times.
455 else if(!(DMaps[currdmap].flags&dmfCAVES))
21110 {
21111
3/6
✓ Branch 0 taken 254 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 252 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
254 if((!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr[1].flags9&fBELOWRETURN)) && tmpscr[1].room==rSP_ITEM
21112
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 161 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
254 && (currscr==128 || !get_bit(quest_rules,qr_ITEMSINPASSAGEWAYS)))
21113 {
21114 93 Item=tmpscr[1].catchall;
21115
21116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if(Item)
21117
2/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
186 items.add(new item((zfix)tmpscr->itemx,
21118
4/14
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 93 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 93 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 93 times.
✗ Branch 13 not taken.
93 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_bit(quest_rules, qr_NOITEMOFFSET)?0:1),
21119
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 93 times.
✗ Branch 9 not taken.
93 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
21120 93 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
21121 93 }
21122 254 }
21123 5142 }
21124
21125 298 void never_return(int32_t index)
21126 {
21127
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 74 times.
298 if(!get_bit(quest_rules,qr_KILLALL))
21128 74 goto doit;
21129
21130
2/2
✓ Branch 0 taken 951 times.
✓ Branch 1 taken 101 times.
1052 for(int32_t i=0; i<guys.Count(); i++)
21131
4/4
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 669 times.
✓ Branch 2 taken 123 times.
✓ Branch 3 taken 159 times.
951 if(((((enemy*)guys.spr(i))->d->flags)&guy_neverret) && i!=index)
21132 {
21133 123 goto dontdoit;
21134 101 }
21135
21136 doit:
21137 175 setmapflag(mNEVERRET);
21138 dontdoit:
21139 298 return;
21140 }
21141
21142 13606 bool slowguy(int32_t id)
21143 {
21144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13606 times.
13606 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
21145 {
21146 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "slowguy()");
21147 return false;
21148 }
21149 //return (guysbuf[id].step<100);
21150
2/2
✓ Branch 0 taken 11806 times.
✓ Branch 1 taken 1800 times.
13606 switch(id)
21151 {
21152 case eOCTO1S:
21153 case eOCTO2S:
21154 case eOCTO1F:
21155 case eOCTO2F:
21156 case eLEV1:
21157 case eLEV2:
21158 case eROCK:
21159 case eBOULDER:
21160 1800 return true;
21161 }
21162
21163 11806 return false;
21164 13606 }
21165
21166 14668 bool ok2add(int32_t id)
21167 {
21168
2/4
✓ Branch 0 taken 14668 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14668 times.
14668 if( ((unsigned)(id&0xFFF)) > MAXGUYS || id <= 0)
21169 {
21170 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "oktoadd()");
21171 return false;
21172 }
21173
4/4
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 14465 times.
✓ Branch 2 taken 102 times.
✓ Branch 3 taken 101 times.
14668 if(getmapflag(mNEVERRET) && (guysbuf[id].flags & guy_neverret))
21174 101 return false;
21175
21176
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14505 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
14567 switch(guysbuf[id].family)
21177 {
21178 // I added a special case for shooters because having traps on the same screen
21179 // was preventing them from spawning due to TMPNORET. This means they will
21180 // never stay dead, though, so it may not be the best solution. - Saf
21181 case eePROJECTILE:
21182 return true;
21183
21184
21185 case eeDIG:
21186 {
21187
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 30 times.
62 switch(guysbuf[id].misc10)
21188 {
21189 case 1:
21190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(!get_bit(quest_rules,qr_NOTMPNORET))
21191 return !getmapflag(mTMPNORET);
21192
21193 32 return true;
21194
21195 30 case 0:
21196 default:
21197 30 return true;
21198 }
21199 }
21200 case eeGANON:
21201 case eeTRAP:
21202 if ((guysbuf[id].family == eeGANON && !get_bit(quest_rules, qr_CAN_PLACE_GANON))
21203 || (guysbuf[id].family == eeTRAP && !get_bit(quest_rules, qr_CAN_PLACE_TRAPS))) return false;
21204 [[fallthrough]];
21205 default:
21206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14505 times.
14505 if (guysbuf[id].flags2&guy_ignoretmpnr) return true;
21207 14505 break;
21208 }
21209
21210
2/2
✓ Branch 0 taken 8744 times.
✓ Branch 1 taken 5761 times.
14505 if(!get_bit(quest_rules,qr_NOTMPNORET))
21211 5761 return !getmapflag(mTMPNORET);
21212
21213 8744 return true;
21214 14668 }
21215
21216 165764 void activate_fireball_statue(int32_t pos)
21217 {
21218
3/4
✓ Branch 0 taken 62873 times.
✓ Branch 1 taken 102891 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62873 times.
165764 if(!(tmpscr->enemyflags&efFIREBALLS) || statueID<0)
21219 {
21220 102891 return;
21221 }
21222
21223 62873 int32_t cx=-1000, cy=-1000;
21224 62873 int32_t x = (pos&15)<<4;
21225 62873 int32_t y = pos&0xF0;
21226
21227 62873 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
21228
21229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62873 times.
62873 if(!isfixedtogrid(statueID))
21230 {
21231
2/2
✓ Branch 0 taken 738 times.
✓ Branch 1 taken 62135 times.
62873 if(ctype==cL_STATUE)
21232 {
21233 738 cx=x+4;
21234 738 cy=y+7;
21235 738 }
21236
2/2
✓ Branch 0 taken 722 times.
✓ Branch 1 taken 61413 times.
62135 else if(ctype==cR_STATUE)
21237 {
21238 722 cx=x-8;
21239 722 cy=y-1;
21240 722 }
21241
1/2
✓ Branch 0 taken 61413 times.
✗ Branch 1 not taken.
61413 else if(ctype==cC_STATUE)
21242 {
21243 cx=x;
21244 cy=y;
21245 }
21246 62873 }
21247 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
21248 {
21249 cx=x;
21250 cy=y;
21251 }
21252
21253
2/2
✓ Branch 0 taken 61413 times.
✓ Branch 1 taken 1460 times.
62873 if(cx!=-1000) // No point creating it if this is false
21254 {
21255
2/2
✓ Branch 0 taken 5006 times.
✓ Branch 1 taken 1460 times.
6466 for(int32_t j=0; j<guys.Count(); j++)
21256 {
21257
3/4
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 4143 times.
✓ Branch 2 taken 863 times.
✗ Branch 3 not taken.
5006 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
21258 {
21259 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
21260 return; // No point deleting it. A script might be toying with it in some way.
21261 else
21262 guys.del(j);
21263 }
21264 5006 }
21265
21266 1460 addenemy(cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
21267 1460 }
21268 165764 }
21269
21270 5122 void activate_fireball_statues()
21271 {
21272
2/2
✓ Branch 0 taken 343 times.
✓ Branch 1 taken 4779 times.
5122 if(!(tmpscr->enemyflags&efFIREBALLS))
21273 {
21274 4779 return;
21275 }
21276
21277
2/2
✓ Branch 0 taken 343 times.
✓ Branch 1 taken 60368 times.
60711 for(int32_t i=0; i<176; i++)
21278 {
21279 60368 activate_fireball_statue(i);
21280 60368 }
21281 5122 }
21282
21283 5122 void load_default_enemies()
21284 {
21285 5122 wallm_load_clk=frame-80;
21286 5122 int32_t Id=0;
21287
21288
2/2
✓ Branch 0 taken 4257 times.
✓ Branch 1 taken 865 times.
5122 if(tmpscr->enemyflags&efZORA)
21289 {
21290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 if(zoraID>=0)
21291 865 addenemy(-16, -16, zoraID, 0);
21292 865 }
21293
21294
2/2
✓ Branch 0 taken 5062 times.
✓ Branch 1 taken 60 times.
5122 if(tmpscr->enemyflags&efTRAP4)
21295 {
21296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(cornerTrapID>=0)
21297 {
21298 60 addenemy(32, 32, cornerTrapID, -14);
21299 60 addenemy(208, 32, cornerTrapID, -14);
21300 60 addenemy(32, 128, cornerTrapID, -14);
21301 60 addenemy(208, 128, cornerTrapID, -14);
21302 60 }
21303 60 }
21304
21305
2/2
✓ Branch 0 taken 56342 times.
✓ Branch 1 taken 5122 times.
61464 for(int32_t y=0; y<176; y+=16)
21306 {
21307
2/2
✓ Branch 0 taken 901472 times.
✓ Branch 1 taken 56342 times.
957814 for(int32_t x=0; x<256; x+=16)
21308 {
21309 901472 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
21310 901472 int32_t cflag = MAPFLAG(x, y);
21311 901472 int32_t cflag_i = MAPCOMBOFLAG(x, y);
21312
21313
4/6
✓ Branch 0 taken 901472 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 901454 times.
✓ Branch 3 taken 18 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 901454 times.
901472 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
21314 {
21315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(trapLOSHorizontalID>=0)
21316 18 addenemy(x, y, trapLOSHorizontalID, -14);
21317 18 }
21318
3/6
✓ Branch 0 taken 901454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 901454 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 901454 times.
901454 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
21319 {
21320 if(trapLOSVerticalID>=0)
21321 addenemy(x, y, trapLOSVerticalID, -14);
21322 }
21323
4/6
✓ Branch 0 taken 901454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 901442 times.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 901442 times.
901454 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
21324 {
21325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(trapLOS4WayID>=0)
21326 {
21327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(addenemy(x, y, trapLOS4WayID, -14))
21328 12 guys.spr(guys.Count()-1)->dummy_int[1]=2;
21329 12 }
21330 12 }
21331
21332
4/6
✓ Branch 0 taken 901442 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 901438 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 901438 times.
901442 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
21333 {
21334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(trapConstantHorizontalID>=0)
21335 4 addenemy(x, y, trapConstantHorizontalID, -14);
21336 4 }
21337
3/6
✓ Branch 0 taken 901438 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 901438 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 901438 times.
901438 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
21338 {
21339 if(trapConstantVerticalID>=0)
21340 addenemy(x, y, trapConstantVerticalID, -14);
21341 }
21342
21343
1/2
✓ Branch 0 taken 901472 times.
✗ Branch 1 not taken.
901472 if(ctype==cSPINTILE1)
21344 {
21345 // Awaken spinning tile
21346 awaken_spinning_tile(tmpscr,COMBOPOS(x,y));
21347 }
21348 901472 }
21349 56342 }
21350
21351
2/2
✓ Branch 0 taken 5090 times.
✓ Branch 1 taken 32 times.
5122 if(tmpscr->enemyflags&efTRAP2)
21352 {
21353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(centerTrapID>=-1)
21354 {
21355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(addenemy(64, 80, centerTrapID, -14))
21356 32 guys.spr(guys.Count()-1)->dummy_int[1]=1;
21357
21358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(addenemy(176, 80, centerTrapID, -14))
21359 32 guys.spr(guys.Count()-1)->dummy_int[1]=1;
21360 32 }
21361 32 }
21362
21363
2/2
✓ Branch 0 taken 5079 times.
✓ Branch 1 taken 43 times.
5122 if(tmpscr->enemyflags&efROCKS)
21364 {
21365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(rockID>=0)
21366 {
21367 43 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
21368 43 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
21369 43 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
21370 43 }
21371 43 }
21372
21373 5122 activate_fireball_statues();
21374 5122 }
21375
21376 6386521 void update_slope_combopos(int32_t lyr, int32_t pos)
21377 {
21378
2/4
✓ Branch 0 taken 6386521 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6386521 times.
6386521 if(unsigned(lyr) > 6 || unsigned(pos) > 175) return;
21379 6386521 mapscr* s = FFCore.tempScreens[lyr];
21380 6386521 newcombo const& cmb = combobuf[s->data[pos]];
21381
21382 6386521 auto id = (176*lyr)+pos;
21383 6386521 auto it = slopes.find(id);
21384
21385 6386521 bool wasSlope = it!=slopes.end();
21386 6386521 bool isSlope = cmb.type == cSLOPE;
21387
21388
3/4
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 6386451 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
6386521 if(isSlope && !wasSlope)
21389 {
21390 70 slopes.try_emplace(id, &(s->data[pos]), nullptr, id, pos);
21391 70 }
21392
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6386451 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6386451 else if(wasSlope && !isSlope)
21393 {
21394 slopes.erase(it);
21395 }
21396 6386521 }
21397 5145 void update_slope_comboposes()
21398 {
21399
2/2
✓ Branch 0 taken 36015 times.
✓ Branch 1 taken 5145 times.
41160 for(auto lyr = 0; lyr < 7; ++lyr)
21400 {
21401
2/2
✓ Branch 0 taken 6338640 times.
✓ Branch 1 taken 36015 times.
6374655 for(auto pos = 0; pos < 176; ++pos)
21402 6338640 update_slope_combopos(lyr,pos);
21403 36015 }
21404 5145 }
21405
21406 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
21407 // There's 2 routines because it's unclear if combobuf or tmpscr->data gets modified. -L
21408 105396 void screen_combo_modify_preroutine(mapscr *s, int32_t pos)
21409 {
21410 105396 delete_fireball_shooter(s, pos);
21411 105396 }
21412
21413 //Placeholder in case we need it.
21414 void screen_ffc_modify_preroutine(word index)
21415 {
21416 return;
21417 }
21418
21419 // Everything that must be done after we change a screen's combo to another combo. -L
21420 105396 void screen_combo_modify_postroutine(mapscr *s, int32_t pos)
21421 {
21422 105396 s->valid |= mVALID;
21423 105396 activate_fireball_statue(pos);
21424
21425
1/2
✓ Branch 0 taken 105396 times.
✗ Branch 1 not taken.
105396 if(combobuf[s->data[pos]].type==cSPINTILE1)
21426 {
21427 // Awaken spinning tile
21428 awaken_spinning_tile(s,pos);
21429 }
21430 105396 int32_t lyr = -1;
21431
2/2
✓ Branch 0 taken 81971 times.
✓ Branch 1 taken 23425 times.
105396 if(s == tmpscr) lyr = 0;
21432
2/2
✓ Branch 0 taken 57515 times.
✓ Branch 1 taken 438119 times.
495634 else for(size_t q = 0; q < 6; ++q)
21433 {
21434
2/2
✓ Branch 0 taken 24456 times.
✓ Branch 1 taken 413663 times.
438119 if(s == tmpscr2+q)
21435 {
21436 24456 lyr = q+1;
21437 24456 break;
21438 }
21439 413663 }
21440
2/2
✓ Branch 0 taken 57515 times.
✓ Branch 1 taken 47881 times.
105396 if(lyr > -1)
21441 47881 update_slope_combopos(lyr,pos);
21442 105396 }
21443
21444 938805 void screen_ffc_modify_postroutine(word index)
21445 {
21446 938805 ffcdata& ff = tmpscr->ffcs[index];
21447 938805 newcombo const& cmb = combobuf[ff.getData()];
21448
21449 938805 auto id = (176*7)+int32_t(index);
21450 938805 auto it = slopes.find(id);
21451
21452 938805 bool wasSlope = it!=slopes.end();
21453
2/2
✓ Branch 0 taken 938703 times.
✓ Branch 1 taken 102 times.
938805 bool isSlope = cmb.type == cSLOPE && !(ff.flags&ffCHANGER);
21454
3/4
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 938713 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 92 times.
938805 if(isSlope && !wasSlope)
21455 {
21456 92 slopes.try_emplace(id, nullptr, &ff, id);
21457 92 }
21458
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 938712 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
938713 else if(wasSlope && !isSlope)
21459 {
21460 1 slopes.erase(it);
21461 1 }
21462 938805 }
21463
21464 void screen_combo_modify_pre(int32_t cid)
21465 {
21466 for(auto lyr = 0; lyr < 7; ++lyr)
21467 {
21468 mapscr* t = FFCore.tempScreens[lyr];
21469 for(int32_t i = 0; i < 176; i++)
21470 {
21471 if(t->data[i] == cid)
21472 {
21473 screen_combo_modify_preroutine(t,i);
21474 }
21475 }
21476 }
21477 }
21478 void screen_combo_modify_post(int32_t cid)
21479 {
21480 for(auto lyr = 0; lyr < 7; ++lyr)
21481 {
21482 mapscr* t = FFCore.tempScreens[lyr];
21483 for(int32_t i = 0; i < 176; i++)
21484 {
21485 if(t->data[i] == cid)
21486 {
21487 screen_combo_modify_postroutine(t,i);
21488 }
21489 }
21490 }
21491 for(word ind = 0; ind < MAXFFCS; ++ind)
21492 {
21493 if(tmpscr->ffcs[ind].getData() == cid)
21494 screen_ffc_modify_postroutine(ind);
21495 }
21496 }
21497
21498 void awaken_spinning_tile(mapscr *s, int32_t pos)
21499 {
21500 addenemy((pos&15)<<4,pos&0xF0,(s->cset[pos]<<12)+eSPINTILE1,combobuf[s->data[pos]].o_tile+zc_max(1,combobuf[s->data[pos]].frames));
21501 }
21502
21503
21504 // It stands for next_side_pos
21505 5215 void nsp(bool random)
21506 // moves sle_x and sle_y to the next position
21507 {
21508
2/2
✓ Branch 0 taken 2937 times.
✓ Branch 1 taken 2278 times.
5215 if(random)
21509 {
21510
2/2
✓ Branch 0 taken 1473 times.
✓ Branch 1 taken 1464 times.
2937 if(zc_oldrand()%2)
21511 {
21512 1473 sle_x = (zc_oldrand()%2) ? 0 : 240;
21513 1473 sle_y = (zc_oldrand()%10)*16;
21514 1473 }
21515 else
21516 {
21517 1464 sle_y = (zc_oldrand()%2) ? 0 : 160;
21518 1464 sle_x = (zc_oldrand()%15)*16;
21519 }
21520
21521 2937 return;
21522 }
21523
21524
2/2
✓ Branch 0 taken 1640 times.
✓ Branch 1 taken 638 times.
2278 if(sle_x==0)
21525 {
21526
2/2
✓ Branch 0 taken 582 times.
✓ Branch 1 taken 56 times.
638 if(sle_y<160)
21527 582 sle_y+=16;
21528 else
21529 56 sle_x+=16;
21530 638 }
21531
2/2
✓ Branch 0 taken 772 times.
✓ Branch 1 taken 868 times.
1640 else if(sle_y==160)
21532 {
21533
2/2
✓ Branch 0 taken 725 times.
✓ Branch 1 taken 47 times.
772 if(sle_x<240)
21534 725 sle_x+=16;
21535 else
21536 47 sle_y-=16;
21537 772 }
21538
2/2
✓ Branch 0 taken 402 times.
✓ Branch 1 taken 466 times.
868 else if(sle_x==240)
21539 {
21540
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 36 times.
402 if(sle_y>0)
21541 366 sle_y-=16;
21542 else
21543 36 sle_x-=16;
21544 402 }
21545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 466 times.
466 else if(sle_y==0)
21546 {
21547
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 if(sle_x>0)
21548 466 sle_x-=16;
21549 else
21550 sle_y+=16;
21551 466 }
21552 5215 }
21553
21554 1118 int32_t next_side_pos(bool random)
21555 // moves sle_x and sle_y to the next available position
21556 // returns the direction the enemy should face
21557 {
21558 bool blocked;
21559 1118 int32_t c=0;
21560
21561 1118 do
21562 {
21563
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 5199 times.
5215 nsp(c>35 ? false : random);
21564
3/4
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 4098 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1117 times.
6332 blocked = _walkflag(sle_x,sle_y,2) || _walkflag(sle_x,sle_y+8,2) ||
21565
1/2
✓ Branch 0 taken 1117 times.
✗ Branch 1 not taken.
1117 (combo_class_buf[COMBOTYPE(sle_x,sle_y)].block_enemies ||
21566
2/4
✓ Branch 0 taken 1117 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1117 times.
✗ Branch 3 not taken.
1117 MAPFLAG(sle_x,sle_y) == mfNOENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOENEMY ||
21567
2/4
✓ Branch 0 taken 1117 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1117 times.
1117 MAPFLAG(sle_x,sle_y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOGROUNDENEMY ||
21568 1117 iswaterex(MAPCOMBO(sle_x,sle_y), currmap, currscr, -1, sle_x, sle_y, true));
21569
21570
2/2
✓ Branch 0 taken 5214 times.
✓ Branch 1 taken 1 times.
5215 if(++c>50)
21571 1 return -1;
21572
2/2
✓ Branch 0 taken 4097 times.
✓ Branch 1 taken 1117 times.
5214 }
21573 5214 while(blocked);
21574
21575 1117 int32_t dir=0;
21576
21577
2/2
✓ Branch 0 taken 794 times.
✓ Branch 1 taken 323 times.
1117 if(sle_x==0) dir=right;
21578
21579
2/2
✓ Branch 0 taken 869 times.
✓ Branch 1 taken 248 times.
1117 if(sle_y==0) dir=down;
21580
21581
2/2
✓ Branch 0 taken 766 times.
✓ Branch 1 taken 351 times.
1117 if(sle_x==240) dir=left;
21582
21583
1/2
✓ Branch 0 taken 1117 times.
✗ Branch 1 not taken.
1117 if(sle_y==168) dir=up;
21584
21585 1117 return dir;
21586 1118 }
21587
21588 bool can_side_load(int32_t id)
21589 {
21590 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
21591 {
21592 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "can_side_load()");
21593 return false;
21594 }
21595 switch(guysbuf[id].family) //id&0x0FFF)
21596 {
21597 //case eTEK1:
21598 //case eTEK2:
21599 //case eTEK3:
21600 //case eLEV1:
21601 //case eLEV2:
21602 //case eLEV3:
21603 //case eRAQUAM:
21604 //case eLAQUAM:
21605 //case eDODONGO:
21606 //case eMANHAN:
21607 //case eGLEEOK1:
21608 //case eGLEEOK2:
21609 //case eGLEEOK3:
21610 //case eGLEEOK4:
21611 //case eDIG1:
21612 //case eDIG3:
21613 //case eGOHMA1:
21614 //case eGOHMA2:
21615 //case eCENT1:
21616 //case eCENT2:
21617 //case ePATRA1:
21618 //case ePATRA2:
21619 //case eGANON:
21620 //case eMANHAN2:
21621 //case eCEILINGM: later
21622 //case eFLOORM: later
21623 //case ePATRABS:
21624 //case ePATRAL2:
21625 //case ePATRAL3:
21626 //case eGLEEOK1F:
21627 //case eGLEEOK2F:
21628 //case eGLEEOK3F:
21629 //case eGLEEOK4F:
21630 //case eDODONGOBS:
21631 //case eDODONGOF:
21632 //case eGOHMA3:
21633 //case eGOHMA4:
21634 //case eSHOOTMAGIC:
21635 //case eSHOOTROCK:
21636 //case eSHOOTSPEAR:
21637 //case eSHOOTSWORD:
21638 //case eSHOOTFLAME:
21639 //case eSHOOTFLAME2:
21640 //case eSHOOTFBALL:
21641 case eeTEK:
21642 case eeLEV:
21643 case eeAQUA:
21644 case eeDONGO:
21645 case eeMANHAN:
21646 case eeGLEEOK:
21647 case eeDIG:
21648 case eeGHOMA:
21649 case eeLANM:
21650 case eePATRA:
21651 case eeGANON:
21652 case eePROJECTILE:
21653 return false;
21654 break;
21655 }
21656
21657 return true;
21658 }
21659
21660 static bool script_sle = false;
21661 static int32_t sle_pattern = 0;
21662 void script_side_load_enemies()
21663 {
21664 if(script_sle || sle_clk) return;
21665 sle_cnt = 0;
21666 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
21667 ++sle_cnt;
21668 script_sle = true;
21669 sle_pattern = tmpscr->pattern;
21670 sle_clk = 0;
21671 }
21672
21673 24933 void side_load_enemies()
21674 {
21675
3/4
✓ Branch 0 taken 24933 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24596 times.
✓ Branch 3 taken 337 times.
24933 if(!script_sle && sle_clk==0)
21676 {
21677 337 sle_pattern = tmpscr->pattern;
21678 337 sle_cnt = 0;
21679 337 int32_t guycnt = 0;
21680 337 int16_t s = (currmap<<7)+currscr;
21681 337 bool beenhere=false;
21682 337 bool reload=true;
21683 337 bool unbeatablereload = true;
21684
21685 337 load_default_enemies();
21686
21687
2/2
✓ Branch 0 taken 2022 times.
✓ Branch 1 taken 337 times.
2359 for(int32_t i=0; i<6; i++)
21688
2/2
✓ Branch 0 taken 1924 times.
✓ Branch 1 taken 98 times.
2120 if(visited[i]==s)
21689 98 beenhere=true;
21690
21691
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 239 times.
337 if(!beenhere)
21692 {
21693 239 visited[vhead]=s;
21694 239 vhead = (vhead+1)%6;
21695 239 }
21696
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 22 times.
98 else if(game->guys[s]==0)
21697 {
21698 22 sle_cnt=0;
21699 22 reload=false;
21700 22 }
21701
21702
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 77 times.
337 if(reload)
21703 {
21704 77 sle_cnt = game->guys[s];
21705
21706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if((get_bit(quest_rules, qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
21707
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 119 times.
77 || sle_cnt==0)
21708 {
21709
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 664 times.
✓ Branch 2 taken 546 times.
✓ Branch 3 taken 119 times.
665 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
21710 546 ++sle_cnt;
21711 119 }
21712
3/4
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 239 times.
315 if (!beenhere && get_bit(quest_rules, qr_UNBEATABLES_DONT_KEEP_DEAD))
21713 {
21714 for(int32_t i = 0; i<sle_cnt && tmpscr->enemy[i]>0; i++)
21715 {
21716 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesntcount))
21717 {
21718 unbeatablereload = false;
21719 }
21720 }
21721 if (unbeatablereload)
21722 {
21723 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
21724 {
21725 ++sle_cnt;
21726 }
21727 }
21728 }
21729 315 }
21730
21731
4/4
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 238 times.
✓ Branch 2 taken 238 times.
✓ Branch 3 taken 99 times.
575 if((get_bit(quest_rules,qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN))
21732 {
21733 476 sle_cnt = 0;
21734
21735
0/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
476 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
21736 ++sle_cnt;
21737 }
21738
21739
2/2
✓ Branch 0 taken 1107 times.
✓ Branch 1 taken 99 times.
1206 for(int32_t i=0; i<sle_cnt; i++)
21740 1107 ++guycnt;
21741
21742 99 game->guys[s] = guycnt;
21743 99 }
21744
21745
2/2
✓ Branch 0 taken 23577 times.
✓ Branch 1 taken 1118 times.
24695 if((++sle_clk+8)%24 == 0)
21746 {
21747 1118 int32_t dir = next_side_pos(sle_pattern==pSIDESR);
21748
21749
4/4
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 1016 times.
1118 if(dir==-1 || tooclose(sle_x,sle_y,32))
21750 {
21751 102 return;
21752 }
21753
21754 1016 int32_t enemy_slot=guys.Count();
21755
21756
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1016 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1016 times.
1016 while(sle_cnt > 0 && !ok2add(tmpscr->enemy[sle_cnt-1]))
21757 sle_cnt--;
21758
21759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1016 times.
1016 if(sle_cnt > 0)
21760 {
21761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1016 times.
1016 if(addenemy(sle_x,sle_y,tmpscr->enemy[--sle_cnt],0))
21762 {
21763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1016 times.
1016 if (((enemy*)guys.spr(enemy_slot))->family != eeTEK)
21764 {
21765 1016 guys.spr(enemy_slot)->dir = dir;
21766 1016 }
21767 1016 }
21768 1016 }
21769 1016 }
21770
21771
2/2
✓ Branch 0 taken 24302 times.
✓ Branch 1 taken 291 times.
24593 if(sle_cnt<=0)
21772 {
21773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 291 times.
291 if(script_sle)
21774 script_sle = false;
21775 291 else loaded_enemies=true;
21776 291 sle_clk = 0;
21777 291 }
21778 24695 }
21779
21780 947967 bool is_starting_pos(int32_t i, int32_t x, int32_t y, int32_t t)
21781 {
21782
21783
4/4
✓ Branch 0 taken 861171 times.
✓ Branch 1 taken 86796 times.
✓ Branch 2 taken 86796 times.
✓ Branch 3 taken 947967 times.
947967 if(tmpscr->enemy[i]<1||tmpscr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
21784 {
21785 //zprint2("is_starting_pos(), tmpscr->enemy[i] is: %d\n", tmpscr->enemy[i]);
21786 173592 return false; //never 0, never OoB.
21787 }
21788 // No corner enemies
21789
6/6
✓ Branch 0 taken 808129 times.
✓ Branch 1 taken 139838 times.
✓ Branch 2 taken 33754 times.
✓ Branch 3 taken 841883 times.
✓ Branch 4 taken 96440 times.
✓ Branch 5 taken 77152 times.
947967 if((x==0 || x==240) && (y==0 || y==160))
21790
21791 173592 return false;
21792
21793 //Is a no spawn combo...
21794
2/4
✓ Branch 0 taken 841883 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 841883 times.
841883 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
21795 return false;
21796
21797 // No enemies in dungeon walls
21798
10/10
✓ Branch 0 taken 614236 times.
✓ Branch 1 taken 227647 times.
✓ Branch 2 taken 543696 times.
✓ Branch 3 taken 70540 times.
✓ Branch 4 taken 473156 times.
✓ Branch 5 taken 70540 times.
✓ Branch 6 taken 388508 times.
✓ Branch 7 taken 84648 times.
✓ Branch 8 taken 84648 times.
✓ Branch 9 taken 303860 times.
841883 if(isdungeon() && (x<32 || x>=224 || y<32 || y>=144))
21799 310376 return false;
21800
21801 // Too close
21802
4/4
✓ Branch 0 taken 58543 times.
✓ Branch 1 taken 472964 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 58542 times.
531507 if(tooclose(x,y,40) && t<11)
21803 58542 return false;
21804
21805 // Can't fly onto it?
21806
4/4
✓ Branch 0 taken 72609 times.
✓ Branch 1 taken 400356 times.
✓ Branch 2 taken 33413 times.
✓ Branch 3 taken 117 times.
506495 if(isflier(tmpscr->enemy[i])&&
21807
1/2
✓ Branch 0 taken 72609 times.
✗ Branch 1 not taken.
72609 (flyerblocked(x+8,y+8,spw_floater,guysbuf[tmpscr->enemy[i]])||
21808
2/2
✓ Branch 0 taken 33530 times.
✓ Branch 1 taken 39079 times.
72609 (_walkflag(x,y+8,2)&&!get_bit(quest_rules,qr_WALLFLIERS))))
21809 117 return false;
21810
21811 // Can't jump onto it?
21812 if
21813 (
21814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82960 times.
555808 guysbuf[tmpscr->enemy[i]].family==eeTEK
21815
21816
2/2
✓ Branch 0 taken 82960 times.
✓ Branch 1 taken 389888 times.
472848 &&
21817 (
21818
1/2
✓ Branch 0 taken 82960 times.
✗ Branch 1 not taken.
82960 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
21819
1/2
✓ Branch 0 taken 82960 times.
✗ Branch 1 not taken.
82960 COMBOTYPE(x+8,y+8)==cNOENEMY||
21820
1/2
✓ Branch 0 taken 82960 times.
✗ Branch 1 not taken.
82960 ispitfall(x+8,y+8)||
21821
1/2
✓ Branch 0 taken 82960 times.
✗ Branch 1 not taken.
82960 MAPFLAG(x+8,y+8)==mfNOENEMY||
21822 82960 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
21823 )
21824 )
21825 {
21826 return false;
21827 }
21828
21829 // Other off-limit combos
21830
6/6
✓ Branch 0 taken 400356 times.
✓ Branch 1 taken 72492 times.
✓ Branch 2 taken 317396 times.
✓ Branch 3 taken 82960 times.
✓ Branch 4 taken 184654 times.
✓ Branch 5 taken 132742 times.
790244 if((!isflier(tmpscr->enemy[i])&& guysbuf[tmpscr->enemy[i]].family!=eeTEK &&
21831
2/2
✓ Branch 0 taken 187360 times.
✓ Branch 1 taken 130036 times.
317396 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[tmpscr->enemy[i]]))) &&
21832 317396 guysbuf[tmpscr->enemy[i]].family!=eeZORA)
21833 132742 return false;
21834
21835 // Don't ever generate enemies on these combos!
21836
3/4
✓ Branch 0 taken 339807 times.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 339807 times.
340106 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
21837 299 return false;
21838
21839 //BS Dodongos need at least 2 spaces.
21840
3/4
✓ Branch 0 taken 931 times.
✓ Branch 1 taken 338876 times.
✓ Branch 2 taken 931 times.
✗ Branch 3 not taken.
339807 if((guysbuf[tmpscr->enemy[i]].family==eeDONGO)&&(guysbuf[tmpscr->enemy[i]].misc10==1))
21841 {
21842 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
21843 ((x>224)||_walkflag(x+16,y+8, 2))&&
21844 ((y<16) ||_walkflag(x, y-8, 2))&&
21845 ((y>144)||_walkflag(x, y+24,2)))
21846 {
21847 return false;
21848 }
21849 }
21850
21851 339807 return true;
21852 861171 }
21853
21854 27078 bool is_ceiling_pattern(int32_t i)
21855 {
21856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27078 times.
27078 return (i==pCEILING || i==pCEILINGR);
21857 }
21858
21859 4822 int32_t placeenemy(int32_t i)
21860 {
21861 4822 std::map<int32_t, int32_t> freeposcache;
21862 4822 int32_t frees = 0;
21863
21864
2/2
✓ Branch 0 taken 53042 times.
✓ Branch 1 taken 4822 times.
57864 for(int32_t y=0; y<176; y+=16)
21865 {
21866
2/2
✓ Branch 0 taken 848672 times.
✓ Branch 1 taken 53042 times.
901714 for(int32_t x=0; x<256; x+=16)
21867 {
21868
3/4
✓ Branch 0 taken 848672 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 331022 times.
✓ Branch 3 taken 517650 times.
848672 if(is_starting_pos(i,x,y,0))
21869 {
21870
1/2
✓ Branch 0 taken 331022 times.
✗ Branch 1 not taken.
331022 freeposcache[frees++] = (y&0xF0)+(x>>4);
21871 331022 }
21872 848672 }
21873 53042 }
21874
21875
2/2
✓ Branch 0 taken 4821 times.
✓ Branch 1 taken 1 times.
4822 if(frees > 0)
21876
2/4
✓ Branch 0 taken 4821 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4821 times.
✗ Branch 3 not taken.
4821 return freeposcache[zc_oldrand()%frees];
21877
21878 1 return -1;
21879 4822 }
21880
21881 13653 void spawnEnemy(int& pos, int& clk, int& x, int& y, int& fastguys, int& i, int& guycnt, int& loadcnt)
21882 {
21883 13653 bool placed=false;
21884 13653 int32_t t=-1;
21885
21886 // First: enemy combo flags
21887
2/2
✓ Branch 0 taken 149948 times.
✓ Branch 1 taken 13607 times.
163555 for(int32_t sy=0; sy<176; sy+=16)
21888 {
21889
2/2
✓ Branch 0 taken 2398770 times.
✓ Branch 1 taken 149902 times.
2548672 for(int32_t sx=0; sx<256; sx+=16)
21890 {
21891 2398770 int32_t cflag = MAPFLAG(sx, sy);
21892 2398770 int32_t cflag_i = MAPCOMBOFLAG(sx, sy);
21893
21894
2/4
✓ Branch 0 taken 2398770 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2398770 times.
✗ Branch 3 not taken.
2398770 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
21895 {
21896 if(!ok2add(tmpscr->enemy[i]))
21897 {
21898 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
21899 }
21900 else
21901 {
21902 addenemy(sx,
21903 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
21904 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
21905
21906 ++guycnt;
21907
21908 placed=true;
21909 goto placed_enemy;
21910 }
21911 }
21912
21913
4/4
✓ Branch 0 taken 2398724 times.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 2398724 times.
✓ Branch 3 taken 46 times.
2398770 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
21914 {
21915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
46 if(!ok2add(tmpscr->enemy[i]))
21916 {
21917 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
21918 }
21919 else
21920 {
21921 92 addenemy(sx,
21922
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
46 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
21923
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
46 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
21924
21925 46 ++guycnt;
21926
21927 46 placed=true;
21928 46 goto placed_enemy;
21929 }
21930 }
21931 2398724 }
21932 149902 }
21933
21934 // Next: enemy pattern
21935
6/8
✓ Branch 0 taken 4809 times.
✓ Branch 1 taken 8798 times.
✓ Branch 2 taken 8789 times.
✓ Branch 3 taken 4818 times.
✓ Branch 4 taken 8789 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 8789 times.
13607 if((tmpscr->pattern==pRANDOM || tmpscr->pattern==pCEILING) && !(isSideViewGravity()) && ((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS)))
21936 {
21937 8789 do
21938 {
21939
21940 // NES positions
21941 12503 pos%=9;
21942 12503 x=stx[loadside][pos];
21943 12503 y=sty[loadside][pos];
21944 12503 ++pos;
21945 12503 ++t;
21946
2/2
✓ Branch 0 taken 3714 times.
✓ Branch 1 taken 8789 times.
21292 }
21947
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12499 times.
12503 while((t< 20) && !is_starting_pos(i,x,y,t));
21948 8789 }
21949
21950
4/4
✓ Branch 0 taken 8789 times.
✓ Branch 1 taken 4818 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 8785 times.
13607 if(t<0 || t >= 20) // above enemy pattern failed
21951 {
21952 // Final chance: find a random position anywhere onscreen
21953 4822 int32_t randpos = placeenemy(i);
21954
21955
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4821 times.
4822 if(randpos>-1)
21956 {
21957 4821 x=(randpos&15)<<4;
21958 4821 y= randpos&0xF0;
21959 4821 }
21960 else // All opportunities failed - abort
21961 {
21962 1 return;
21963 }
21964 4821 }
21965
21966 {
21967 13606 int32_t c=0;
21968 13606 c=clk;
21969
21970
2/2
✓ Branch 0 taken 1800 times.
✓ Branch 1 taken 11806 times.
13606 if(!slowguy(tmpscr->enemy[i]))
21971 11806 ++fastguys;
21972
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 1402 times.
1800 else if(fastguys>0)
21973 398 c=-15*(i-fastguys+2);
21974 else
21975 1402 c=-15*(i+1);
21976
21977
4/6
✓ Branch 0 taken 429 times.
✓ Branch 1 taken 13177 times.
✓ Branch 2 taken 429 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 429 times.
13606 if(BSZ&&((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
21978 {
21979 // Special case for blue leevers
21980
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 429 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
429 if(guysbuf[tmpscr->enemy[i]].family==eeLEV && guysbuf[tmpscr->enemy[i]].misc1==1)
21981 c=-15*(i+1);
21982 else
21983 429 c=-15;
21984 429 }
21985
21986
2/2
✓ Branch 0 taken 13493 times.
✓ Branch 1 taken 113 times.
13606 if(!ok2add(tmpscr->enemy[i]))
21987 {
21988
4/6
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 21 times.
113 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
21989 113 }
21990 else
21991 {
21992
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13493 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13493 if(((tmpscr->enemy[i]>0||tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
21993 {
21994
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13493 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26986 addenemy(x,(is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
21995
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13493 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13493 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],c);
21996
21997 13493 ++guycnt;
21998 13493 }
21999 }
22000
22001 13606 placed=true;
22002 13606 } // if(t < 20)
22003
22004 placed_enemy:
22005
22006 // I don't like this, but it seems to work...
22007 static bool foundCarrier;
22008
22009
2/2
✓ Branch 0 taken 10652 times.
✓ Branch 1 taken 3000 times.
13652 if(i==0)
22010 3000 foundCarrier=false;
22011
22012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13652 times.
13652 if(placed)
22013 {
22014
4/4
✓ Branch 0 taken 3000 times.
✓ Branch 1 taken 10652 times.
✓ Branch 2 taken 2879 times.
✓ Branch 3 taken 121 times.
13652 if(i==0 && tmpscr->enemyflags&efLEADER)
22015 {
22016 121 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
22017
22018
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 7 times.
121 if(index!=-1)
22019 {
22020 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
22021
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114 if ((((enemy*)guys.spr(index))->family == eeLANM) && !get_bit(quest_rules, qr_NO_LANMOLA_RINGLEADER)) index = guys.idNth(tmpscr->enemy[i], 2, 0xFFF);
22022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(index!=-1)
22023 {
22024 114 ((enemy*)guys.spr(index))->leader = true;
22025 114 }
22026 114 }
22027 121 }
22028
22029
4/4
✓ Branch 0 taken 13598 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 13583 times.
✓ Branch 3 taken 15 times.
13652 if(!foundCarrier && hasitem&(4|2))
22030 {
22031 15 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
22032
22033
2/4
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
15 if(index!=-1 && (((enemy*)guys.spr(index))->flags&guy_doesntcount)==0)
22034 {
22035 15 ((enemy*)guys.spr(index))->itemguy = true;
22036 15 foundCarrier=true;
22037 15 }
22038 15 }
22039 13652 }
22040 13653 }
22041
22042 bool scriptloadenemies()
22043 {
22044 loaded_enemies = true;
22045 if(script_sle || sle_clk) return false;
22046 if(tmpscr->pattern==pNOSPAWN) return false;
22047
22048 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
22049 {
22050 script_side_load_enemies();
22051 return true;
22052 }
22053
22054 int32_t pos=zc_oldrand()%9;
22055 int32_t clk=-15,x=0,y=0,fastguys=0;
22056 int32_t i=0,guycnt=0;
22057 int32_t loadcnt = 10;
22058
22059 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
22060 {
22061 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
22062
22063 --clk;
22064 }
22065 return true;
22066 }
22067
22068 2801993 void loadenemies()
22069 {
22070
3/4
✓ Branch 0 taken 2801993 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24596 times.
✓ Branch 3 taken 2777397 times.
2801993 if(script_sle || sle_clk)
22071 {
22072 24596 side_load_enemies();
22073 24596 return;
22074 }
22075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2777397 times.
2777397 if(tmpscr->pattern==pNOSPAWN) return;
22076
2/2
✓ Branch 0 taken 2772273 times.
✓ Branch 1 taken 5124 times.
2777397 if(loaded_enemies)
22077 2772273 return;
22078
22079 // check if it's the dungeon boss and it has been beaten before
22080
4/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 5088 times.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 2 times.
5124 if(tmpscr->enemyflags&efBOSS && game->lvlitems[dlevel]&liBOSS)
22081 {
22082 2 loaded_enemies = true;
22083 2 return;
22084 }
22085
22086
4/4
✓ Branch 0 taken 4988 times.
✓ Branch 1 taken 134 times.
✓ Branch 2 taken 203 times.
✓ Branch 3 taken 4785 times.
5122 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
22087 {
22088 337 side_load_enemies();
22089 337 return;
22090 }
22091
22092 4785 loaded_enemies=true;
22093
22094 // do enemies that are always loaded
22095 4785 load_default_enemies();
22096
22097 // dungeon basements
22098
22099 static byte dngn_enemy_x[4] = {32,96,144,208};
22100
22101
2/2
✓ Branch 0 taken 455 times.
✓ Branch 1 taken 4330 times.
4785 if(currscr>=128)
22102 {
22103
2/2
✓ Branch 0 taken 201 times.
✓ Branch 1 taken 254 times.
455 if(DMaps[currdmap].flags&dmfCAVES) return;
22104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 254 times.
254 if ( DMaps[currdmap].flags&dmfNEWCELLARENEMIES )
22105 {
22106 for(int32_t i=0; i<10; i++)
22107 {
22108 if ( tmpscr->enemy[i] )
22109 {
22110 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i],-14-i);
22111 }
22112 }
22113 }
22114 else
22115 {
22116
2/2
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 254 times.
1270 for(int32_t i=0; i<4; i++)
22117
2/2
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 200 times.
1016 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i]?tmpscr->enemy[i]:(int32_t)eKEESE1,-14-i);
22118 }
22119 254 return;
22120 }
22121
22122 // check if it's been long enough to reload all enemies
22123
22124 4330 int32_t loadcnt = 10;
22125 4330 int16_t s = (currmap<<7)+currscr;
22126 4330 bool beenhere = false;
22127 4330 bool reload = true;
22128 4330 bool unbeatablereload = true;
22129
22130
2/2
✓ Branch 0 taken 25980 times.
✓ Branch 1 taken 4330 times.
30310 for(int32_t i=0; i<6; i++)
22131
2/2
✓ Branch 0 taken 24889 times.
✓ Branch 1 taken 1091 times.
27071 if(visited[i]==s)
22132 1091 beenhere = true;
22133
22134
2/2
✓ Branch 0 taken 1091 times.
✓ Branch 1 taken 3239 times.
4330 if(!beenhere) //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
22135 {
22136 3239 visited[vhead]=s; //If not, it adds it to the array,
22137 3239 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
22138 3239 }
22139
2/2
✓ Branch 0 taken 473 times.
✓ Branch 1 taken 618 times.
1091 else if(game->guys[s]==0) //Then, if you have been here, and the number of enemies left on the screen is 0,
22140 {
22141 618 loadcnt = 0; //It will tell it not to load any enemies,
22142 618 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
22143 618 }
22144
22145
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 3712 times.
4330 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
22146 {
22147 3712 loadcnt = game->guys[s]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
22148
22149
2/4
✓ Branch 0 taken 968 times.
✓ Branch 1 taken 2744 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3712 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
22150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 968 times.
968 (get_bit(quest_rules, qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
22151 2744 loadcnt = 10; //That means all enemies need to be respawned.
22152
3/4
✓ Branch 0 taken 3239 times.
✓ Branch 1 taken 473 times.
✓ Branch 2 taken 3239 times.
✗ Branch 3 not taken.
3712 if (!beenhere && get_bit(quest_rules, qr_UNBEATABLES_DONT_KEEP_DEAD))
22153 {
22154 for(int32_t i = 0; i<loadcnt && tmpscr->enemy[i]>0; i++)
22155 {
22156 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesntcount))
22157 {
22158 unbeatablereload = false;
22159 }
22160 }
22161 if (unbeatablereload)
22162 {
22163 loadcnt = 10;
22164 }
22165 }
22166 3712 }
22167
22168
3/4
✓ Branch 0 taken 4330 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 4324 times.
4330 if((get_bit(quest_rules,qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
22169 6 loadcnt = 10; //All enemies also need to be respawned.
22170
22171 4330 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
22172 4330 int32_t clk=-15,x=0,y=0,fastguys=0; //clk being negative means the enemy is in it's spawn poof.
22173 4330 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
22174
22175
4/4
✓ Branch 0 taken 1671 times.
✓ Branch 1 taken 16312 times.
✓ Branch 2 taken 13653 times.
✓ Branch 3 taken 4330 times.
17983 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
22176 {
22177 13653 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
22178
22179 13653 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
22180 13653 }
22181
22182 4330 game->guys[s] = guycnt;
22183 //} //if(true)
22184 2801993 }
22185 65 void moneysign()
22186 {
22187 65 additem(48,108,iRupy,ipDUMMY);
22188 // textout(scrollbuf,zfont,"X",64,112,CSET(0)+1);
22189 65 set_clip_state(pricesdisplaybuf, 0);
22190 65 textout_ex(pricesdisplaybuf,zfont,"X",64,112,CSET(0)+1,-1);
22191 65 }
22192
22193 360 void putprices(bool sign)
22194 {
22195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 360 times.
360 if(fadeclk > 0) return;
22196 // refresh what's under the prices
22197 // for(int32_t i=5; i<12; i++)
22198 // putcombo(scrollbuf,i<<4,112,tmpscr->data[112+i],tmpscr->cpage);
22199
22200 360 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
22201 360 int32_t step=32;
22202 360 int32_t x=80;
22203
22204
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 271 times.
360 if(prices[2]==0)
22205 {
22206 271 step<<=1;
22207
22208
2/2
✓ Branch 0 taken 253 times.
✓ Branch 1 taken 18 times.
271 if(prices[1]==0)
22209 {
22210 253 x=112;
22211 253 }
22212 271 }
22213
22214
2/2
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 1080 times.
1440 for(int32_t i=0; i<3; i++)
22215 {
22216 // Kind of stupid, but it works: 100000 is used to indicate that an item
22217 // has a price of zero rather than there being no item.
22218 // 100000 isn't a valid price, so this doesn't cause problems.
22219
3/4
✓ Branch 0 taken 321 times.
✓ Branch 1 taken 759 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 321 times.
1080 if(prices[i]!=0 && prices[i]<100000)
22220 {
22221 char buf[8];
22222 321 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
22223
22224 321 int32_t l=(int32_t)strlen(buf);
22225 321 set_clip_state(pricesdisplaybuf, 0);
22226
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 307 times.
321 textout_ex(pricesdisplaybuf,zfont,buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
22227 321 }
22228
22229 1080 x+=step;
22230 1080 }
22231 360 }
22232
22233 // Setting up special rooms
22234 // Also called when the Letter is used successfully.
22235 299 void setupscreen()
22236 {
22237 299 boughtsomething=false;
22238 299 int32_t t=currscr<128?0:1;
22239 299 word str=tmpscr[t].str;
22240
22241 // Prices are already set to 0 in dowarp()
22242
12/15
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 122 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 29 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 9 times.
✓ Branch 10 taken 20 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 4 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 12 times.
299 switch(tmpscr[t].room)
22243 {
22244 case rSP_ITEM: // special item
22245 43 additem(120,89,tmpscr[t].catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
22246 43 break;
22247
22248 case rINFO: // pay for info
22249 {
22250 3 int32_t count = 0;
22251 3 int32_t base = 88;
22252 3 int32_t step = 5;
22253
22254 3 moneysign();
22255
22256
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 9 times.
12 for(int32_t i=0; i<3; i++)
22257 {
22258
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(QMisc.info[tmpscr[t].catchall].str[i])
22259 {
22260 9 ++count;
22261 9 }
22262 else
22263 break;
22264 9 }
22265
22266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(count)
22267 {
22268
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(count==1)
22269 {
22270 base = 88+32;
22271 }
22272
22273
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(count==2)
22274 {
22275 step = 6;
22276 }
22277
22278
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 3 times.
12 for(int32_t i=0; i < count; i++)
22279 {
22280 9 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
22281 9 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
22282 9 prices[i] = -(QMisc.info[tmpscr[t].catchall].price[i]);
22283
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(prices[i]==0)
22284 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
22285 9 int32_t itemid = current_item_id(itype_wealthmedal);
22286
22287
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if(itemid>=0 && prices[i]!=100000)
22288 {
22289 if(itemsbuf[itemid].flags & ITEM_FLAG1)
22290 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
22291 else
22292 prices[i]-=itemsbuf[itemid].misc1;
22293 prices[i]=vbound(prices[i], -99999, 0);
22294 if(prices[i]==0)
22295 prices[i]=100000;
22296 }
22297
22298
2/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9 if((QMisc.info[tmpscr[t].catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
22299 prices[i]=-1;
22300 9 }
22301 3 }
22302
22303 3 break;
22304 }
22305
22306 case rMONEY: // secret money
22307 29 additem(120,89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
22308 29 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22309 29 break;
22310
22311 case rGAMBLE: // gambling
22312 4 prices[0]=prices[1]=prices[2]=-10;
22313 4 moneysign();
22314 4 additem(88,89,iRupy,ipMONEY+ipDUMMY);
22315 4 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22316 4 additem(120,89,iRupy,ipMONEY+ipDUMMY);
22317 4 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
22318 4 additem(152,89,iRupy,ipMONEY+ipDUMMY);
22319 4 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
22320 4 break;
22321
22322 case rREPAIR: // door repair
22323
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
22324 // }
22325 10 repaircharge=tmpscr[t].catchall;
22326 10 break;
22327
22328 case rMUPGRADE: // upgrade magic
22329 adjustmagic=true;
22330 break;
22331
22332 case rLEARNSLASH: // learn slash attack
22333 1 learnslash=true;
22334 1 break;
22335
22336 case rRP_HC: // heart container or red potion
22337 9 additem(88,89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
22338 9 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22339 9 additem(152,89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
22340 9 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
22341 9 break;
22342
22343 case rP_SHOP: // potion shop
22344
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 17 times.
20 if(current_item(itype_letter)<i_letter_used)
22345 {
22346 3 str=0;
22347 3 break;
22348 }
22349
22350 [[fallthrough]];
22351 case rTAKEONE: // take one
22352 case rSHOP: // shop
22353 {
22354 59 int32_t count = 0;
22355 59 int32_t base = 88;
22356 59 int32_t step = 5;
22357
22358
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 58 times.
59 if(tmpscr[t].room != rTAKEONE)
22359 58 moneysign();
22360
22361 //count and align the stuff
22362
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 173 times.
222 for(int32_t i=0; i<3; ++i)
22363 {
22364
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 10 times.
173 if(QMisc.shop[tmpscr[t].catchall].hasitem[count] != 0)
22365 {
22366 163 ++count;
22367 163 }
22368 else
22369 {
22370 10 break;
22371 }
22372 163 }
22373
22374
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 4 times.
59 if(count==1)
22375 {
22376 4 base = 88+32;
22377 4 }
22378
22379
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 6 times.
59 if(count==2)
22380 {
22381 6 step = 6;
22382 6 }
22383
22384
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 59 times.
222 for(int32_t i=0; i<count; i++)
22385 {
22386 163 additem((i<<step)+base, 89, QMisc.shop[tmpscr[t].catchall].item[i], ipHOLDUP+ipFADE+(tmpscr[t].room == rTAKEONE ? ipONETIME2 : ipCHECK));
22387 163 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
22388
22389
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 161 times.
163 if(tmpscr[t].room != rTAKEONE)
22390 {
22391 161 prices[i] = QMisc.shop[tmpscr[t].catchall].price[i];
22392
1/2
✓ Branch 0 taken 161 times.
✗ Branch 1 not taken.
161 if(prices[i]==0)
22393 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
22394 161 int32_t itemid = current_item_id(itype_wealthmedal);
22395
22396
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 161 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
161 if(itemid>=0 && prices[i]!=100000)
22397 {
22398 if(itemsbuf[itemid].flags & ITEM_FLAG1)
22399 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
22400 else
22401 prices[i]+=itemsbuf[itemid].misc1;
22402 prices[i]=vbound(prices[i], 0, 99999);
22403 if(prices[i]==0)
22404 prices[i]=100000;
22405 }
22406
22407
2/4
✓ Branch 0 taken 161 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 161 times.
✗ Branch 3 not taken.
161 if((QMisc.shop[tmpscr[t].catchall].price[i])>1 && prices[i]<1)
22408 prices[i]=1;
22409 161 }
22410 163 }
22411
22412 59 break;
22413 }
22414 case rBOTTLESHOP: // bottle shop
22415 {
22416 int32_t count = 0;
22417 int32_t base = 88;
22418 int32_t step = 5;
22419
22420 moneysign();
22421 bottleshoptype const& bst = QMisc.bottle_shop_types[tmpscr[t].catchall];
22422 //count and align the stuff
22423 for(int32_t i=0; i<3; ++i)
22424 {
22425 if(bst.fill[count] != 0)
22426 {
22427 ++count;
22428 }
22429 else
22430 {
22431 break;
22432 }
22433 }
22434
22435 if(count==1)
22436 {
22437 base = 88+32;
22438 }
22439
22440 if(count==2)
22441 {
22442 step = 6;
22443 }
22444
22445 for(int32_t i=0; i<count; i++)
22446 {
22447 adddummyitem((i<<step)+base, 89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
22448 //{ Setup dummy item
22449 item* curItem = ((item*)items.spr(items.Count()-1));
22450 curItem->PriceIndex = i;
22451 newcombo const& cmb = combobuf[bst.comb[i]];
22452 curItem->o_tile = cmb.o_tile;
22453 curItem->o_cset = bst.cset[i];
22454 curItem->cs = curItem->o_cset;
22455 curItem->tile = cmb.o_tile;
22456 curItem->o_speed = cmb.speed;
22457 curItem->o_delay = 0;
22458 curItem->frames = cmb.frames;
22459 curItem->flip = cmb.flip;
22460 curItem->family = itype_bottlefill; //no pickup w/o empty bottle
22461 curItem->pstring = 0;
22462 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
22463 curItem->flash = false;
22464 curItem->twohand = false;
22465 curItem->anim = true;
22466 curItem->hxsz=1;
22467 curItem->hyofs=4;
22468 curItem->hysz=12;
22469 curItem->script=0;
22470 curItem->txsz=1;
22471 curItem->tysz=1;
22472 //}
22473
22474 prices[i] = bst.price[i];
22475 if(prices[i]==0)
22476 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
22477 int32_t itemid = current_item_id(itype_wealthmedal);
22478
22479 if(itemid>=0 && prices[i]!=100000)
22480 {
22481 if(itemsbuf[itemid].flags & ITEM_FLAG1)
22482 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
22483 else
22484 prices[i]+=itemsbuf[itemid].misc1;
22485 prices[i]=vbound(prices[i], 0, 99999);
22486 if(prices[i]==0)
22487 prices[i]=100000;
22488 }
22489
22490 if((bst.price[i])>1 && prices[i]<1)
22491 prices[i]=1;
22492 }
22493
22494 break;
22495 }
22496
22497 case rBOMBS: // more bombs
22498 4 additem(120,89,iRupy,ipDUMMY+ipMONEY);
22499 4 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22500 4 prices[0]=-tmpscr[t].catchall;
22501 4 break;
22502
22503 case rARROWS: // more arrows
22504 additem(120,89,iRupy,ipDUMMY+ipMONEY);
22505 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22506 prices[0]=-tmpscr[t].catchall;
22507 break;
22508
22509 case rSWINDLE: // leave heart container or money
22510 12 additem(88,89,iHeartC,ipDUMMY+ipMONEY);
22511 12 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22512 12 prices[0]=-1;
22513 12 additem(152,89,iRupy,ipDUMMY+ipMONEY);
22514 12 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
22515 12 prices[1]=-tmpscr[t].catchall;
22516 12 break;
22517
22518 }
22519
22520
3/4
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 295 times.
299 if(tmpscr[t].room == rBOMBS || tmpscr[t].room == rARROWS)
22521 {
22522 4 int32_t i = (tmpscr[t].room == rSWINDLE ? 1 : 0);
22523 4 int32_t itemid = current_item_id(itype_wealthmedal);
22524
22525
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(itemid >= 0)
22526 {
22527 if(itemsbuf[itemid].flags & ITEM_FLAG1)
22528 prices[i]*=(itemsbuf[itemid].misc1/100.0);
22529 else
22530 prices[i]+=itemsbuf[itemid].misc1;
22531 }
22532
22533
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(tmpscr[t].catchall>1 && prices[i]>-1)
22534 prices[i]=-1;
22535 4 }
22536
22537 299 putprices(false);
22538
22539
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 16 times.
299 if(str)
22540 {
22541 283 donewmsg(str);
22542 283 }
22543 else
22544 {
22545 16 Hero.unfreeze();
22546 }
22547 299 }
22548
22549 // Increments msgptr and returns the control code argument pointed at.
22550 word grab_next_argument()
22551 {
22552 if(unsigned(msgptr+1)>=MsgStrings[msgstr].s.size()) return 0;
22553 byte val=MsgStrings[msgstr].s[++msgptr]-1;
22554 word ret=val;
22555
22556 // If an argument is succeeded by 255, then it's a three-byte argument -
22557 // between 254 and 65535 (or whatever the maximum actually is)
22558 if((unsigned(msgptr+2)<MsgStrings[msgstr].s.size())
22559 && uint8_t(MsgStrings[msgstr].s[msgptr+1]) == 255)
22560 {
22561 val=MsgStrings[msgstr].s[msgptr+2];
22562 word next=val;
22563 ret += 254*next;
22564 msgptr+=2;
22565 }
22566
22567 return ret;
22568 }
22569
22570 enum
22571 {
22572 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
22573 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
22574
22575 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
22576
22577 MNU_DATA_MAX
22578 };
22579 struct menu_choice
22580 {
22581 int32_t x, y;
22582 int32_t pos;
22583 int32_t upos, dpos, lpos, rpos;
22584 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
22585 {}
22586 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
22587 int32_t dpos, int32_t lpos, int32_t rpos)
22588 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
22589 {}
22590 };
22591 static int32_t msg_menu_data[MNU_DATA_MAX];
22592 static bool do_run_menu = false;
22593 bool do_end_str = false;
22594 static bool wait_advance = false;
22595 14 static std::map<int32_t, menu_choice> menu_options;
22596 5672 void clr_msg_data()
22597 {
22598 5672 do_end_str = false;
22599 5672 wait_advance = false;
22600 5672 do_run_menu = false;
22601 5672 menu_options.clear();
22602 5672 memset(msg_menu_data, 0, sizeof(msg_menu_data));
22603 5672 }
22604
22605 static bool doing_name_insert = false;
22606 static char namebuf[9] = {0};
22607 static char* nameptr = NULL;
22608 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
22609 bool runMenuCursor()
22610 {
22611 clear_bitmap(msg_menu_bmp_buf);
22612 if(!menu_options.size())
22613 {
22614 msg_menu_data[MNU_CHOSEN] = 0;
22615 return true; //end menu
22616 }
22617 int32_t pos = msg_menu_data[MNU_CHOSEN];
22618 //If the cursor is at an invalid pos, find the first pos >= 0...
22619 if(menu_options.find(pos) == menu_options.end())
22620 {
22621 pos = 0;
22622 while(menu_options.find(pos) == menu_options.end())
22623 ++pos;
22624 }
22625 menu_choice* ch = &menu_options[pos];
22626
22627 bool pressed = true;
22628 if(rUp()) pos = ch->upos;
22629 else if(rDown()) pos = ch->dpos;
22630 else if(rLeft()) pos = ch->lpos;
22631 else if(rRight()) pos = ch->rpos;
22632 else pressed = false;
22633
22634 if(pressed)
22635 msg_menu_data[MNU_TIMER] = 1;
22636
22637 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 5);
22638 bool held = false;
22639 if(hold_input)
22640 {
22641 held = true;
22642 if(Up()) pos = ch->upos;
22643 else if(Down()) pos = ch->dpos;
22644 else if(Left()) pos = ch->lpos;
22645 else if(Right()) pos = ch->rpos;
22646 else held = false;
22647 }
22648 //If the cursor is at an invalid pos, find the first pos >= 0...
22649 if(menu_options.find(pos) == menu_options.end())
22650 {
22651 pos = 0;
22652 while(menu_options.find(pos) == menu_options.end())
22653 ++pos;
22654 }
22655 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
22656 sfx(MsgStrings[msgstr].sfx);
22657
22658 ch = &menu_options[pos];
22659 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
22660 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
22661 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
22662 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
22663
22664 msg_menu_data[MNU_CHOSEN] = pos;
22665
22666 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
22667 {
22668 rAbtn(); //Eat
22669 if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1;
22670 }
22671
22672 bool ret = (pressed || held) ? false : rAbtn();
22673 //Eat inputs
22674 rUp(); rDown(); rLeft(); rRight(); rAbtn();
22675
22676 if(ret)
22677 menu_options.clear();
22678
22679 return ret;
22680 //false if pos changed this frame; no confirming while moving the cursor!
22681 }
22682
22683 50532 bool bottom_margin_clip()
22684 {
22685 50832 return !get_bit(quest_rules, qr_OLD_STRING_EDITOR_MARGINS)
22686
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 50232 times.
50532 && cursor_y >= (msg_h + (get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
22687 }
22688
22689 12617 bool parsemsgcode()
22690 {
22691
2/2
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 12286 times.
12617 if(msgptr>=MsgStrings[msgstr].s.size()) return false;
22692 12286 byte c = byte(MsgStrings[msgstr].s[msgptr]-1);
22693
1/36
✗ Branch 0 not taken.
✓ Branch 1 taken 12286 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
12286 switch(c)
22694 {
22695 case MSGC_NEWLINE:
22696 {
22697 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
22698 ssc_tile_hei = ssc_tile_hei_buf;
22699 ssc_tile_hei_buf = -1;
22700 cursor_y += thei + MsgStrings[msgstr].vspace;
22701 cursor_x=msg_margins[left];
22702 return true;
22703 }
22704
22705 case MSGC_COLOUR:
22706 {
22707 int32_t cset = (grab_next_argument());
22708 msgcolour = CSET(cset)+(grab_next_argument());
22709 return true;
22710 }
22711
22712 case MSGC_SHDCOLOR:
22713 {
22714 int32_t cset = (grab_next_argument());
22715 msg_shdcol = CSET(cset)+(grab_next_argument());
22716 return true;
22717 }
22718 case MSGC_SHDTYPE:
22719 {
22720 msg_shdtype = grab_next_argument();
22721 return true;
22722 }
22723
22724 case MSGC_SPEED:
22725 {
22726 msgspeed=grab_next_argument();
22727 return true;
22728 }
22729
22730 case MSGC_CTRUP:
22731 {
22732 int32_t a1 = grab_next_argument();
22733 int32_t a2 = grab_next_argument();
22734 game->change_counter(a2, a1);
22735 return true;
22736 }
22737
22738 case MSGC_CTRDN:
22739 {
22740 int32_t a1 = grab_next_argument();
22741 int32_t a2 = grab_next_argument();
22742 game->change_counter(-a2, a1);
22743 return true;
22744 }
22745
22746 case MSGC_CTRSET:
22747 {
22748 int32_t a1 = grab_next_argument();
22749 int32_t a2 = grab_next_argument();
22750 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
22751 return true;
22752 }
22753
22754 case MSGC_CTRUPPC:
22755 case MSGC_CTRDNPC:
22756 case MSGC_CTRSETPC:
22757 {
22758 int32_t code = MsgStrings[msgstr].s[msgptr]-1;
22759 int32_t counter = grab_next_argument();
22760 int32_t amount = grab_next_argument();
22761 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
22762
22763 if(code==MSGC_CTRDNPC)
22764 amount*=-1;
22765
22766 if(code==MSGC_CTRSETPC)
22767 game->set_counter(amount, counter);
22768 else
22769 game->change_counter(amount, counter);
22770
22771 return true;
22772 }
22773
22774 case MSGC_GIVEITEM:
22775 {
22776 int32_t itemID = grab_next_argument();
22777
22778 getitem(itemID, true);
22779 if ( !item_doscript[itemID] && (((unsigned)itemID) < 256) )
22780 {
22781 itemScriptData[itemID].Clear();
22782 memset(item_stack[itemID], 0xFFFF, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
22783 if ( (itemsbuf[itemID].flags&ITEM_PASSIVESCRIPT) ) item_doscript[itemID] = 1;
22784 }
22785 return true;
22786 }
22787
22788
22789 case MSGC_WARP:
22790 {
22791 int32_t dmap = grab_next_argument();
22792 int32_t scrn = grab_next_argument();
22793 int32_t dx = grab_next_argument();
22794 int32_t dy = grab_next_argument();
22795 int32_t wfx = grab_next_argument();
22796 int32_t sfx = grab_next_argument();
22797 if(dx >= MAX_SCC_ARG) dx = -1;
22798 if(dy >= MAX_SCC_ARG) dy = -1;
22799 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, warpFlagDONTKILLMUSIC, 0);
22800 return true;
22801 }
22802
22803 case MSGC_SETSCREEND:
22804 {
22805 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
22806 int32_t screen = grab_next_argument();
22807 int32_t reg = grab_next_argument();
22808 int32_t val = grab_next_argument();
22809 FFCore.set_screen_d(screen + dmap, reg, val);
22810 return true;
22811 }
22812 case MSGC_TAKEITEM:
22813 {
22814 int32_t itemID = grab_next_argument();
22815 if ( item_doscript[itemID] )
22816 {
22817 item_doscript[itemID] = 4; //Val of 4 means 'clear stack and quit'
22818 }
22819 takeitem(itemID);
22820 if ( game->forced_bwpn == itemID )
22821 {
22822 game->forced_bwpn = -1;
22823 } //not else if! -Z
22824 if ( game->forced_awpn == itemID )
22825 {
22826 game->forced_awpn = -1;
22827 }
22828 if ( game->forced_xwpn == itemID )
22829 {
22830 game->forced_xwpn = -1;
22831 } //not else if! -Z
22832 if ( game->forced_ywpn == itemID )
22833 {
22834 game->forced_ywpn = -1;
22835 }
22836 verifyBothWeapons();
22837 return true;
22838 }
22839
22840 case MSGC_SFX:
22841 {
22842 sfx((int32_t)grab_next_argument(),128);
22843 return true;
22844 }
22845
22846 case MSGC_MIDI:
22847 {
22848 int32_t music = (int32_t)(grab_next_argument());
22849
22850 if(music==0)
22851 music_stop();
22852 else
22853 jukebox(music+(ZC_MIDI_COUNT-1));
22854
22855 return true;
22856 }
22857
22858 case MSGC_NAME:
22859 {
22860 doing_name_insert = true;
22861 sprintf(namebuf, "%s", game->get_name());
22862 nameptr = namebuf;
22863 return true;
22864 }
22865
22866 case MSGC_DRAWTILE:
22867 {
22868 int32_t tl = grab_next_argument();
22869 int32_t cs = grab_next_argument();
22870 int32_t t_wid = grab_next_argument();
22871 int32_t t_hei = grab_next_argument();
22872 int32_t fl = grab_next_argument();
22873
22874 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
22875 {
22876 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
22877 ssc_tile_hei = ssc_tile_hei_buf;
22878 ssc_tile_hei_buf = -1;
22879 cursor_y += thei + MsgStrings[msgstr].vspace;
22880 if(bottom_margin_clip()) return true;
22881 cursor_x=msg_margins[left];
22882 }
22883
22884 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
22885 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
22886 cursor_x += MsgStrings[msgstr].hspace + t_wid;
22887 return true;
22888 }
22889
22890 case MSGC_GOTOIFRAND:
22891 {
22892 int32_t odds = (int32_t)(grab_next_argument());
22893
22894 if(!odds || !(zc_oldrand()%odds))
22895 goto switched;
22896
22897 (void)grab_next_argument();
22898 return true;
22899 }
22900
22901 case MSGC_GOTOIFGLOBAL:
22902 {
22903 int32_t arg = (int32_t)grab_next_argument();
22904 int32_t d = zc_min(7,arg);
22905 int32_t s = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
22906 arg = (int32_t)grab_next_argument();
22907
22908 if(game->screen_d[s][d] >= arg)
22909 goto switched;
22910
22911 (void)grab_next_argument();
22912 return true;
22913 }
22914
22915 case MSGC_CHANGEPORTRAIT:
22916 {
22917 return true; //not implemented
22918 }
22919
22920 case MSGC_GOTOIFCREEND:
22921 {
22922 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
22923 int32_t screen = grab_next_argument();
22924 int32_t reg = grab_next_argument();
22925 int32_t val = grab_next_argument();
22926 //int32_t nxtstr = grab_next_argument();
22927 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
22928 {
22929 goto switched;
22930 }
22931 (void)grab_next_argument();
22932 return true;
22933 }
22934
22935 case MSGC_GOTOIF:
22936 {
22937 int32_t it = (int32_t)grab_next_argument();
22938
22939 if(unsigned(it)<MAXITEMS && game->item[it])
22940 goto switched;
22941
22942 (void)grab_next_argument();
22943 return true;
22944 }
22945
22946 case MSGC_GOTOIFCTR:
22947 {
22948 if(game->get_counter(grab_next_argument())>=grab_next_argument())
22949 goto switched;
22950
22951 (void)grab_next_argument();
22952 return true;
22953 }
22954
22955 case MSGC_GOTOIFCTRPC:
22956 {
22957 int32_t counter = grab_next_argument();
22958 int32_t amount = (int32_t)(((grab_next_argument())/100)*game->get_maxcounter(counter));
22959
22960 if(game->get_counter(counter)>=amount)
22961 goto switched;
22962
22963 (void)grab_next_argument();
22964 return true;
22965 }
22966
22967 case MSGC_GOTOIFTRICOUNT:
22968 {
22969 if(TriforceCount() >= (int32_t)(grab_next_argument()))
22970 goto switched;
22971
22972 (void)grab_next_argument();
22973 return true;
22974 }
22975
22976 case MSGC_GOTOIFTRI:
22977 {
22978 int32_t lev = (int32_t)(grab_next_argument());
22979
22980 if(lev<MAXLEVELS && game->lvlitems[lev]&liTRIFORCE)
22981 goto switched;
22982
22983 (void)grab_next_argument();
22984 return true;
22985 }
22986
22987 case MSGC_SETUPMENU:
22988 {
22989 msg_menu_data[MNU_CURSOR_TILE] = grab_next_argument();
22990 msg_menu_data[MNU_CURSOR_CSET] = grab_next_argument();
22991 msg_menu_data[MNU_CURSOR_WID] = grab_next_argument();
22992 msg_menu_data[MNU_CURSOR_HEI] = grab_next_argument();
22993 msg_menu_data[MNU_CURSOR_FLIP] = grab_next_argument();
22994 return true;
22995 }
22996
22997 case MSGC_MENUCHOICE:
22998 {
22999 int32_t pos = grab_next_argument();
23000 int32_t upos = grab_next_argument();
23001 int32_t dpos = grab_next_argument();
23002 int32_t lpos = grab_next_argument();
23003 int32_t rpos = grab_next_argument();
23004 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
23005 {
23006 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23007 ssc_tile_hei = ssc_tile_hei_buf;
23008 ssc_tile_hei_buf = -1;
23009 cursor_y += thei + MsgStrings[msgstr].vspace;
23010 if(bottom_margin_clip()) break;
23011 cursor_x=msg_margins[left];
23012 }
23013
23014 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
23015 upos, dpos, lpos, rpos);
23016
23017 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
23018 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
23019 return true;
23020 }
23021
23022 case MSGC_RUNMENU:
23023 {
23024 msg_menu_data[MNU_CHOSEN] = 0;
23025 msg_menu_data[MNU_CAN_CONFIRM] = 0;
23026 if(menu_options.size() < 1)
23027 return true;
23028 do_run_menu = true;
23029 return true;
23030 }
23031
23032 case MSGC_GOTOMENUCHOICE:
23033 {
23034 int32_t choice = grab_next_argument();
23035 if(msg_menu_data[MNU_CHOSEN] == choice)
23036 goto switched;
23037 (void)grab_next_argument();
23038 return true;
23039 }
23040
23041 case MSGC_ENDSTRING:
23042 {
23043 do_end_str = true;
23044 return true;
23045 }
23046 case MSGC_WAIT_ADVANCE:
23047 {
23048 wait_advance = true;
23049 linkedmsgclk = 51;
23050 return true;
23051 }
23052 case MSGC_TRIGSECRETS:
23053 {
23054 bool perm = (bool)grab_next_argument();
23055 hidden_entrance(0, true, false, -8);
23056 if(perm)
23057 setmapflag(mSECRET);
23058 return true;
23059 }
23060 case MSGC_SETSCREENSTATE:
23061 {
23062 int32_t flag = int32_t(grab_next_argument());
23063 if(unsigned(flag)>=mMAXIND)
23064 {
23065 Z_error("SCC 133: Flag %d is invalid\n", flag);
23066 return true;
23067 }
23068 bool state = bool(grab_next_argument());
23069 if(state)
23070 setmapflag(1<<flag);
23071 else
23072 unsetmapflag(1<<flag,true);
23073 return true;
23074 }
23075 case MSGC_SETSCREENSTATER:
23076 {
23077 int32_t map = (int32_t)grab_next_argument();
23078 int32_t scrid = (int32_t)grab_next_argument();
23079 if(map < 1 || map > map_count)
23080 {
23081 Z_error("SCC 134: Map %d is invalid\n", map);
23082 return true;
23083 }
23084 if(unsigned(scrid)>=0x80)
23085 {
23086 Z_error("SCC 134: Screen %d is invalid\n", scrid);
23087 return true;
23088 }
23089
23090 int32_t flag = int32_t(grab_next_argument());
23091 if(unsigned(flag)>=mMAXIND)
23092 {
23093 Z_error("SCC 134: Flag %d is invalid\n", flag);
23094 return true;
23095 }
23096 bool state = bool(grab_next_argument());
23097 if(state)
23098 setmapflag(mapind(map,scrid),1<<flag);
23099 else
23100 unsetmapflag(mapind(map,scrid),1<<flag,true);
23101 return true;
23102 }
23103 switched:
23104 int32_t lev = (int32_t)(grab_next_argument());
23105 if(lev && get_bit(quest_rules, qr_SCC_GOTO_RESPECTS_CONTFLAG)
23106 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
23107 {
23108 msgstr=lev;
23109 msgpos=msgptr=0;
23110 msgfont=setmsgfont();
23111 }
23112 else donewmsg(lev);
23113 msgptr--; // To counteract it being incremented after this routine is called.
23114 putprices(false);
23115 return true;
23116 }
23117
23118 12286 return false;
23119 12617 }
23120
23121 // Wraps the message string... probably.
23122 12282 void wrapmsgstr(char *s3)
23123 {
23124 12282 int32_t j=0;
23125
23126
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 12186 times.
12282 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
23127 {
23128
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 76 times.
96 if(msgspace)
23129 {
23130 20 char c = MsgStrings[msgstr].s[msgptr];
23131
3/6
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
20 if(c != ' ' && c >= 32 && c <= 126)
23132 {
23133
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 20 times.
97 for(int32_t k=0; MsgStrings[msgstr].s[msgptr+k] && MsgStrings[msgstr].s[msgptr+k] != ' '; k++)
23134 {
23135
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
77 if(MsgStrings[msgstr].s[msgptr+k] >= 32 && MsgStrings[msgstr].s[msgptr+k] <= 126) s3[j++] = MsgStrings[msgstr].s[msgptr+k];
23136 77 }
23137
23138 20 s3[j] = 0;
23139 20 msgspace = false;
23140 20 }
23141 else
23142 {
23143 s3[0] = c;
23144 s3[1] = 0;
23145 }
23146 20 }
23147 else
23148 {
23149 76 s3[0] = MsgStrings[msgstr].s[msgptr];
23150 76 s3[1] = 0;
23151
23152
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 19 times.
76 if(s3[0] == ' ') msgspace=true;
23153 }
23154 96 }
23155 else
23156 {
23157 12186 s3[0] = MsgStrings[msgstr].s[msgptr];
23158 12186 s3[1] = 0;
23159 }
23160 12282 }
23161
23162 // Returns true if the pointer is at a string's
23163 // null terminator or a trailing space
23164 60825 bool atend(char const* str)
23165 {
23166 60825 int32_t i=0;
23167
23168
2/2
✓ Branch 0 taken 873215 times.
✓ Branch 1 taken 60825 times.
934040 while(str[i]==' ')
23169 873215 i++;
23170
23171 60825 return str[i]=='\0';
23172 }
23173
23174 2802928 void putmsg()
23175 {
23176 2802928 bool oldmargin = get_bit(quest_rules, qr_OLD_STRING_EDITOR_MARGINS)!=0;
23177
2/2
✓ Branch 0 taken 2742814 times.
✓ Branch 1 taken 60114 times.
2802928 if(!msgorig) msgorig=msgstr;
23178
23179
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2802928 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2802928 if(wait_advance && linkedmsgclk < 1)
23180 linkedmsgclk = 1;
23181
2/2
✓ Branch 0 taken 2798867 times.
✓ Branch 1 taken 4061 times.
2802928 if(linkedmsgclk>0)
23182 {
23183
2/2
✓ Branch 0 taken 1460 times.
✓ Branch 1 taken 2601 times.
4061 if(linkedmsgclk==1)
23184 {
23185
4/6
✓ Branch 0 taken 1460 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1408 times.
✓ Branch 3 taken 52 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1408 times.
1460 if(do_end_str||cAbtn()||cBbtn())
23186 {
23187 52 do_end_str = false;
23188 52 linkedmsgclk = 0;
23189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if(wait_advance)
23190 {
23191 wait_advance = false;
23192 }
23193 else
23194 {
23195 52 msgstr=MsgStrings[msgstr].nextstring;
23196
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
52 if(!msgstr && enqueued_str)
23197 {
23198 msgstr = enqueued_str;
23199 enqueued_str = 0;
23200 }
23201
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 1 times.
52 if(!msgstr)
23202 {
23203 1 msgfont=zfont;
23204
23205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(tmpscr->room!=rGRUMBLE)
23206 1 blockpath=false;
23207
23208 1 dismissmsg();
23209 1 goto disappear;
23210 }
23211
23212 51 donewmsg(msgstr);
23213 51 putprices(false);
23214 }
23215 51 }
23216 1459 }
23217 else
23218 {
23219 2601 --linkedmsgclk;
23220 }
23221 4060 }
23222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2802927 times.
2802927 if(wait_advance) return; //Waiting for buttonpress
23223
23224
8/10
✓ Branch 0 taken 2802817 times.
✓ Branch 1 taken 110 times.
✓ Branch 2 taken 59719 times.
✓ Branch 3 taken 2743098 times.
✓ Branch 4 taken 59719 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 24970 times.
✓ Branch 7 taken 34749 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 24970 times.
2802927 if(!do_run_menu && (!msgstr || msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip()))
23225 {
23226
2/2
✓ Branch 0 taken 34749 times.
✓ Branch 1 taken 2743098 times.
2777847 if(!msgstr)
23227 2743098 msgorig=0;
23228
23229 2777847 msg_active = false;
23230 2777847 return;
23231 }
23232
23233 25080 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
23234
23235 char s3[145];
23236 int32_t tlength;
23237
23238 // Bypass the string with the B button!
23239
4/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 25025 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 24970 times.
25080 if(((cBbtn())&&(get_bit(quest_rules,qr_ALLOWMSGBYPASS))) || msgspeed==0)
23240 {
23241 //finish writing out the string
23242
0/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
110 while(msgptr<MsgStrings[msgstr].s.size() && !atend(MsgStrings[msgstr].s.c_str()+msgptr))
23243 {
23244 if(msgspeed && !(cBbtn() && get_bit(quest_rules,qr_ALLOWMSGBYPASS)))
23245 goto breakout; // break out if message speed was changed to non-zero
23246 else if(!do_run_menu && !doing_name_insert && !parsemsgcode())
23247 {
23248 if(bottom_margin_clip())
23249 break;
23250
23251 wrapmsgstr(s3);
23252
23253 if(MsgStrings[msgstr].s[msgptr]==' ')
23254 {
23255 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
23256
23257 if(cursor_x+tlength > (msg_w-msg_margins[right])
23258 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23259 ? true : strcmp(s3," ")!=0))
23260 {
23261 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23262 ssc_tile_hei = ssc_tile_hei_buf;
23263 ssc_tile_hei_buf = -1;
23264 cursor_y += thei + MsgStrings[msgstr].vspace;
23265 if(bottom_margin_clip()) break;
23266 cursor_x=msg_margins[left];
23267 }
23268
23269 char buf[2] = {0};
23270 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
23271
23272 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
23273
23274 cursor_x+=tlength;
23275 }
23276 else
23277 {
23278 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
23279 if(cursor_x+tlength > (msg_w-msg_margins[right])
23280 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23281 ? true : strcmp(s3," ")!=0))
23282 {
23283 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23284 ssc_tile_hei = ssc_tile_hei_buf;
23285 ssc_tile_hei_buf = -1;
23286 cursor_y += thei + MsgStrings[msgstr].vspace;
23287 if(bottom_margin_clip()) break;
23288 cursor_x=msg_margins[left];
23289 }
23290
23291 sfx(MsgStrings[msgstr].sfx);
23292
23293 char buf[2] = {0};
23294 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
23295
23296 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
23297
23298 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
23299 cursor_x += MsgStrings[msgstr].hspace;
23300 }
23301
23302 msgpos++;
23303 }
23304 if(do_run_menu)
23305 {
23306 if(runMenuCursor())
23307 {
23308 do_run_menu = false;
23309 }
23310 else break;
23311 }
23312 if(doing_name_insert)
23313 {
23314 if(*nameptr)
23315 {
23316 if(bottom_margin_clip())
23317 break;
23318
23319 char s3[9] = {0};
23320
23321 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
23322 {
23323 strcpy(s3, nameptr);
23324 }
23325 else
23326 {
23327 s3[0] = *nameptr;
23328 s3[1] = 0;
23329 }
23330
23331 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
23332
23333 if(cursor_x+tlength > (msg_w-msg_margins[right])
23334 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23335 ? true : strcmp(s3," ")!=0))
23336 {
23337 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23338 ssc_tile_hei = ssc_tile_hei_buf;
23339 ssc_tile_hei_buf = -1;
23340 cursor_y += thei + MsgStrings[msgstr].vspace;
23341 if(bottom_margin_clip()) break;
23342 cursor_x=msg_margins[left];
23343 }
23344
23345 sfx(MsgStrings[msgstr].sfx);
23346
23347 char buf[2] = {0};
23348 sprintf(buf,"%c",*nameptr);
23349
23350 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
23351
23352 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
23353 cursor_x += MsgStrings[msgstr].hspace;
23354 ++nameptr;
23355 continue; //don't advance the msgptr, as the next char in it was not processed!
23356 }
23357 else doing_name_insert = false;
23358 }
23359 ++msgptr;
23360 if(do_end_str)
23361 goto strendcheck;
23362 if(wait_advance)
23363 return;
23364 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
23365 {
23366 if(MsgStrings[msgstr].nextstring)
23367 {
23368 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
23369 {
23370 msgstr=MsgStrings[msgstr].nextstring;
23371 msgpos=msgptr=0;
23372 msgfont=setmsgfont();
23373 }
23374 }
23375 }
23376 }
23377
23378 if (!do_run_menu)
23379 {
23380 msgclk = 72;
23381 msgpos = 10000;
23382 }
23383 }
23384 else
23385 24970 {
23386 breakout:
23387
23388
6/6
✓ Branch 0 taken 20884 times.
✓ Branch 1 taken 4086 times.
✓ Branch 2 taken 12873 times.
✓ Branch 3 taken 8011 times.
✓ Branch 4 taken 8350 times.
✓ Branch 5 taken 4523 times.
24970 if(((msgclk++)%(msgspeed+1)<msgspeed)&&((!cAbtn())||(!get_bit(quest_rules,qr_ALLOWFASTMSG))))
23389 12534 return;
23390 }
23391
23392 // Start writing the string
23393
2/2
✓ Branch 0 taken 12101 times.
✓ Branch 1 taken 335 times.
12771 if(msgptr == 0)
23394 {
23395
2/2
✓ Branch 0 taken 335 times.
✓ Branch 1 taken 854 times.
1189 while(MsgStrings[msgstr].s[msgptr]==' ')
23396 {
23397 854 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
23398
23399
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
854 if(cursor_x+tlength > (msg_w-msg_margins[right])
23400
1/6
✓ Branch 0 taken 854 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
854 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23401 ? 1 : strcmp(s3," ")!=0))
23402 {
23403 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23404 ssc_tile_hei = ssc_tile_hei_buf;
23405 ssc_tile_hei_buf = -1;
23406 cursor_y += thei + MsgStrings[msgstr].vspace;
23407 if(bottom_margin_clip()) break;
23408 cursor_x=msg_margins[left];
23409 }
23410
23411 854 cursor_x+=tlength;
23412 854 ++msgptr;
23413 854 ++msgpos;
23414
23415 // The "Continue From Previous" feature
23416
1/2
✓ Branch 0 taken 854 times.
✗ Branch 1 not taken.
854 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
23417 {
23418 if(MsgStrings[msgstr].nextstring)
23419 {
23420 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
23421 {
23422 msgstr=MsgStrings[msgstr].nextstring;
23423 msgpos=msgptr=0;
23424 msgfont=setmsgfont();
23425 }
23426 }
23427 }
23428 }
23429 335 }
23430
23431 reparsesinglechar:
23432 // Continue printing the string!
23433
3/4
✓ Branch 0 taken 12282 times.
✓ Branch 1 taken 154 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12282 times.
24718 if(!atend(MsgStrings[msgstr].s.c_str()+msgptr) && !bottom_margin_clip())
23434 {
23435
3/6
✓ Branch 0 taken 12282 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12282 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12282 times.
12282 if(!do_run_menu && !doing_name_insert && !parsemsgcode())
23436 {
23437 12282 wrapmsgstr(s3);
23438
23439 12282 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
23440
23441
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 118 times.
12402 if(cursor_x+tlength > (msg_w-msg_margins[right])
23442
4/6
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 12162 times.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 118 times.
✗ Branch 5 not taken.
12282 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23443 2 ? true : strcmp(s3," ")!=0))
23444 {
23445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23446 120 ssc_tile_hei = ssc_tile_hei_buf;
23447 120 ssc_tile_hei_buf = -1;
23448 120 cursor_y += thei + MsgStrings[msgstr].vspace;
23449
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(bottom_margin_clip()) goto strendcheck;
23450 120 cursor_x=msg_margins[left];
23451 //if(space) s3[0]=0;
23452 120 }
23453
23454 12282 sfx(MsgStrings[msgstr].sfx);
23455
23456 12282 char buf[2] = {0};
23457 12282 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
23458
23459 12282 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
23460
23461 12282 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
23462 12282 cursor_x += MsgStrings[msgstr].hspace;
23463 12282 msgpos++;
23464 12282 }
23465
1/2
✓ Branch 0 taken 12282 times.
✗ Branch 1 not taken.
12282 if(do_end_str)
23466 goto strendcheck;
23467
1/2
✓ Branch 0 taken 12282 times.
✗ Branch 1 not taken.
12282 if(wait_advance)
23468 {
23469 ++msgptr;
23470 return;
23471 }
23472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12282 times.
12282 else if(do_run_menu)
23473 {
23474 if(runMenuCursor())
23475 {
23476 do_run_menu = false;
23477 ++msgptr;
23478 goto reparsesinglechar;
23479 }
23480 }
23481
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12282 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12282 else if(doing_name_insert && *nameptr)
23482 {
23483 char s3[9] = {0};
23484
23485 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
23486 {
23487 strcpy(s3, nameptr);
23488 }
23489 else
23490 {
23491 s3[0] = *nameptr;
23492 s3[1] = 0;
23493 }
23494
23495 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
23496
23497 if(cursor_x+tlength > (msg_w-msg_margins[right])
23498 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23499 ? true : strcmp(s3," ")!=0))
23500 {
23501 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23502 ssc_tile_hei = ssc_tile_hei_buf;
23503 ssc_tile_hei_buf = -1;
23504 cursor_y += thei + MsgStrings[msgstr].vspace;
23505 if(bottom_margin_clip()) goto strendcheck;
23506 cursor_x=msg_margins[left];
23507 }
23508
23509 sfx(MsgStrings[msgstr].sfx);
23510
23511 char buf[2] = {0};
23512 sprintf(buf,"%c",*nameptr);
23513
23514 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
23515
23516 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
23517 cursor_x += MsgStrings[msgstr].hspace;
23518 ++nameptr;
23519 }
23520 else
23521 {
23522 12282 doing_name_insert = false;
23523 12282 msgptr++;
23524
23525
2/2
✓ Branch 0 taken 11947 times.
✓ Branch 1 taken 335 times.
12282 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
23526 {
23527
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 52 times.
335 if(MsgStrings[msgstr].nextstring)
23528 {
23529
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
23530 {
23531 msgstr=MsgStrings[msgstr].nextstring;
23532 msgpos=msgptr=0;
23533 msgfont=setmsgfont();
23534 }
23535 52 }
23536 335 }
23537
23538
2/2
✓ Branch 0 taken 1768 times.
✓ Branch 1 taken 713 times.
14763 if(MsgStrings[msgstr].s.size() > unsigned(msgptr+1)
23539
2/2
✓ Branch 0 taken 12268 times.
✓ Branch 1 taken 14 times.
12282 && (MsgStrings[msgstr].s[msgptr]==' ')
23540
2/2
✓ Branch 0 taken 2481 times.
✓ Branch 1 taken 9787 times.
12268 && (MsgStrings[msgstr].s[msgptr+1]==' '))
23541 {
23542
2/2
✓ Branch 0 taken 713 times.
✓ Branch 1 taken 23148 times.
23861 while(MsgStrings[msgstr].s[msgptr]==' ')
23543 {
23544 23148 msgspace = true;
23545 23148 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
23546
23547
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1054 times.
24203 if(cursor_x+tlength > (msg_w-msg_margins[right])
23548
4/6
✓ Branch 0 taken 1055 times.
✓ Branch 1 taken 22093 times.
✓ Branch 2 taken 1055 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1054 times.
✗ Branch 5 not taken.
23148 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23549 1 ? true : strcmp(s3," ")!=0))
23550 {
23551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1055 times.
1055 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23552 1055 ssc_tile_hei = ssc_tile_hei_buf;
23553 1055 ssc_tile_hei_buf = -1;
23554 1055 cursor_y += thei + MsgStrings[msgstr].vspace;
23555
1/2
✓ Branch 0 taken 1055 times.
✗ Branch 1 not taken.
1055 if(bottom_margin_clip()) break;
23556 1055 cursor_x=msg_margins[left];
23557 1055 }
23558
23559 23148 cursor_x+=tlength;
23560 23148 ++msgpos;
23561 23148 ++msgptr;
23562
23563
2/2
✓ Branch 0 taken 2052 times.
✓ Branch 1 taken 21096 times.
23148 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
23564 {
23565
2/2
✓ Branch 0 taken 17326 times.
✓ Branch 1 taken 3770 times.
21096 if(MsgStrings[msgstr].nextstring)
23566 {
23567
1/2
✓ Branch 0 taken 3770 times.
✗ Branch 1 not taken.
3770 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
23568 {
23569 msgstr=MsgStrings[msgstr].nextstring;
23570 msgpos=msgptr=0;
23571 msgfont=setmsgfont();
23572 }
23573 3770 }
23574 21096 }
23575 }
23576 713 }
23577 }
23578 12282 }
23579 strendcheck:
23580 // Done printing the string
23581
9/14
✓ Branch 0 taken 12436 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12436 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12436 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12436 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12105 times.
✓ Branch 9 taken 331 times.
✓ Branch 10 taken 12105 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 12101 times.
✓ Branch 13 taken 335 times.
12436 if(do_end_str || !doing_name_insert && !do_run_menu && (msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip() || atend(MsgStrings[msgstr].s.c_str()+msgptr)) && !linkedmsgclk)
23582 {
23583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 335 times.
335 if(!do_end_str)
23584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 335 times.
335 while(parsemsgcode()); // Finish remaining control codes
23585
23586 // Go to next string, or make it disappear by going to string 0.
23587
5/6
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 282 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 282 times.
335 if(MsgStrings[msgstr].nextstring!=0 || get_bit(quest_rules,qr_MSGDISAPPEAR) || enqueued_str)
23588 {
23589 53 linkedmsgclk=do_end_str?1:51;
23590 53 }
23591
23592
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 52 times.
335 if(MsgStrings[msgstr].nextstring==0)
23593 {
23594
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 282 times.
283 if(!get_bit(quest_rules,qr_MSGDISAPPEAR))
23595 282 {
23596 disappear:
23597 283 msg_active = false;
23598 283 Hero.finishedmsg();
23599 283 }
23600
23601
2/2
✓ Branch 0 taken 274 times.
✓ Branch 1 taken 10 times.
284 if(repaircharge)
23602 {
23603 // if (get_bit(quest_rules,qr_REPAIRFIX)) {
23604 // fixed_door=true;
23605 // }
23606 10 game->change_drupy(-tmpscr[currscr<128?0:1].catchall);
23607 10 repaircharge = 0;
23608 10 }
23609
23610
1/2
✓ Branch 0 taken 284 times.
✗ Branch 1 not taken.
284 if(adjustmagic)
23611 {
23612 if(get_bit(quest_rules,qr_OLD_HALF_MAGIC))
23613 {
23614 if(game->get_magicdrainrate())
23615 game->set_magicdrainrate(1);
23616 }
23617 else if(game->get_magicdrainrate() > 1)
23618 {
23619 game->set_magicdrainrate(game->get_magicdrainrate()/2);
23620 }
23621 adjustmagic = false;
23622 sfx(WAV_SCALE);
23623 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
23624 }
23625
23626
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 1 times.
284 if(learnslash)
23627 {
23628 1 game->set_canslash(1);
23629 1 learnslash = false;
23630 1 sfx(WAV_SCALE);
23631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
23632 1 }
23633 284 }
23634 336 }
23635 2802818 }
23636
23637 1309 int32_t message_more_y()
23638 {
23639 //Is the flag ticked, do we really want a message more y larger than 160?
23640
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1309 times.
✓ Branch 2 taken 1309 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1309 times.
✗ Branch 5 not taken.
1309 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
23641 1309 msgy+=playing_field_offset;
23642 1309 return msgy;
23643 }
23644
23645 /*** Collision detection & handling ***/
23646
23647 2806022 void clear_script_one_frame_conditions()
23648 {
23649
2/2
✓ Branch 0 taken 10968844 times.
✓ Branch 1 taken 2806022 times.
13774866 for(int32_t j=0; j<guys.Count(); j++)
23650 {
23651 10968844 enemy *e = (enemy*)guys.spr(j);
23652
2/2
✓ Branch 0 taken 175501504 times.
✓ Branch 1 taken 10968844 times.
186470348 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
23653 10968844 }
23654 2806022 }
23655
23656 2805967 void check_collisions()
23657 {
23658 2805967 bool temp_hit = false;
23659
2/2
✓ Branch 0 taken 1646597 times.
✓ Branch 1 taken 2805967 times.
4452564 for(int32_t i=0; i<Lwpns.Count(); i++)
23660 {
23661 1646597 weapon *w = (weapon*)Lwpns.spr(i);
23662
23663
7/8
✓ Branch 0 taken 1422203 times.
✓ Branch 1 taken 224394 times.
✓ Branch 2 taken 1198085 times.
✓ Branch 3 taken 224118 times.
✓ Branch 4 taken 1198085 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10628 times.
✓ Branch 7 taken 1187457 times.
1646597 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
23664 {
23665
2/2
✓ Branch 0 taken 1181366 times.
✓ Branch 1 taken 4512951 times.
5694317 for(int32_t j=0; j<guys.Count(); j++)
23666 {
23667 4512951 enemy *e = (enemy*)guys.spr(j);
23668
2/2
✓ Branch 0 taken 44428 times.
✓ Branch 1 taken 4468523 times.
4512951 if ( !temp_hit ) e->hitby[HIT_BY_LWEAPON] = 0;
23669
23670
2/2
✓ Branch 0 taken 4420425 times.
✓ Branch 1 taken 92526 times.
4512951 if(e->hit(w)) //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
23671 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
23672 {
23673 // !(e->stunclk)
23674 92526 int32_t h = e->takehit(w);
23675
2/2
✓ Branch 0 taken 79002 times.
✓ Branch 1 taken 13524 times.
92526 if (h == -1)
23676 {
23677 13524 e->hitby[HIT_BY_LWEAPON] = i+1; temp_hit = true;
23678 13524 e->hitby[HIT_BY_LWEAPON_UID] = w->script_UID;
23679 //e->hitby[HIT_BY_LWEAPON_FAMILY] = itemsbuf[w->parentid].family; //that would be the itemclass, not the weapon type!
23680 13524 e->hitby[HIT_BY_LWEAPON_FAMILY] = w->id;
23681 //al_trace("npc->HitBy[] Parent Item is: %d /n", w->parentitem);
23682 //al_trace("npc->HitBy[] Parent ID is: %d /n", w->parentid);
23683 13524 e->hitby[HIT_BY_LWEAPON_LITERAL_ID] = w->parentitem;
23684
23685 13524 }
23686 //we may need to handle this in special cases. -Z
23687
23688 //if h == stun or ignore
23689
23690 //if e->stun > DEFAULT_STUN -1 || !e->stun
23691 //if the enemy wasn't stunned this round -- what a bitch, as the stun value is set before we check this
23692 ///! how about: if w->dead != bounce !
23693
23694 // NOT FOR PUBLIC RELEASE
23695 /*if(h==3) //Mirror shield
23696 {
23697 if (w->id==ewFireball || w->id==wRefFireball)
23698 {
23699 w->id=wRefFireball;
23700 switch(e->dir)
23701 {
23702 case up: e->angle += (PI - e->angle) * 2.0; break;
23703 case down: e->angle = -e->angle; break;
23704 case left: e->angle += ((-PI/2) - e->angle) * 2.0; break;
23705 case right: e->angle += (( PI/2) - e->angle) * 2.0; break;
23706 // TODO: the following. -L.
23707 case l_up: break;
23708 case r_up: break;
23709 case l_down: break;
23710 case r_down: break;
23711 }
23712 }
23713 else
23714 {
23715 w->id = ((w->id==ewMagic || w->id==wRefMagic || w->id==wMagic) ? wRefMagic : wRefBeam);
23716 w->dir ^= 1;
23717 if(w->dir&2)
23718 w->flip ^= 1;
23719 else
23720 w->flip ^= 2;
23721 }
23722 w->ignoreHero=false;
23723 }
23724 else*/
23725
2/2
✓ Branch 0 taken 75185 times.
✓ Branch 1 taken 17341 times.
92526 if(h)
23726 {
23727
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 17341 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17341 if(e->switch_hooked && w->family_class == itype_switchhook)
23728 w->onhit(false, e, -1);
23729 17341 else w->onhit(false, e, h);
23730 17341 }
23731
23732
2/2
✓ Branch 0 taken 90667 times.
✓ Branch 1 taken 1859 times.
92526 if(h==2)
23733 {
23734 1859 break;
23735 }
23736 90667 }
23737
23738
2/2
✓ Branch 0 taken 4506860 times.
✓ Branch 1 taken 4232 times.
4511092 if(w->Dead())
23739 {
23740 4232 break;
23741 }
23742 4506860 }
23743
23744 // Item flags added in 2.55:
23745 // BRang/HShot/Arrows ITEM_FLAG4 is "Pick up anything" (port of qr_BRANGPICKUP)
23746 // BRang/HShot ITEM_FLAG5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
23747 // Arrows ITEM_FLAG2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
23748 // -V
23749
6/6
✓ Branch 0 taken 1027138 times.
✓ Branch 1 taken 160319 times.
✓ Branch 2 taken 1026866 times.
✓ Branch 3 taken 272 times.
✓ Branch 4 taken 4486 times.
✓ Branch 5 taken 1022380 times.
1187457 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
23750 {
23751 165077 int32_t itype, pitem = w->parentitem;
23752
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 160319 times.
✓ Branch 2 taken 4486 times.
✓ Branch 3 taken 272 times.
165077 switch(w->id)
23753 {
23754 160319 case wBrang: itype = itype_brang; break;
23755 4486 case wArrow: itype = itype_arrow; break;
23756 case wHookshot:
23757 272 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
23758 272 break;
23759 }
23760
1/2
✓ Branch 0 taken 165077 times.
✗ Branch 1 not taken.
165077 if(pitem < 0) pitem = current_item_id(itype);
23761
3/6
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 164805 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 272 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165077 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & ITEM_FLAG9))
23762 { //Swap with item
23763 for(int32_t j=0; j<items.Count(); j++)
23764 {
23765 if(items.spr(j)->hit(w))
23766 {
23767 item *theItem = ((item*)items.spr(j));
23768 bool priced = theItem->PriceIndex >-1;
23769 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
23770 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
23771 || (((itemsbuf[w->parentitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & ITEM_FLAG7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
23772 {
23773 if(!Hero.switchhookclk)
23774 {
23775 hooked_combopos = -1;
23776 hooked_layerbits = 0;
23777 switching_object = theItem;
23778 theItem->switch_hooked = true;
23779 w->misc = 2;
23780 w->step = 0;
23781 theItem->clk2=256;
23782 Hero.doSwitchHook(game->get_switchhookstyle());
23783 if(QMisc.miscsfx[sfxSWITCHED])
23784 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(w->x));
23785 }
23786 }
23787 }
23788 }
23789 }
23790
6/6
✓ Branch 0 taken 4486 times.
✓ Branch 1 taken 160591 times.
✓ Branch 2 taken 164816 times.
✓ Branch 3 taken 160330 times.
✓ Branch 4 taken 160591 times.
✓ Branch 5 taken 160330 times.
165077 else if((w->id==wArrow&&itemsbuf[pitem].flags & ITEM_FLAG2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & ITEM_FLAG5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
23791 {
23792
2/2
✓ Branch 0 taken 39703 times.
✓ Branch 1 taken 164816 times.
204519 for(int32_t j=0; j<items.Count(); j++)
23793 {
23794
2/2
✓ Branch 0 taken 37844 times.
✓ Branch 1 taken 1859 times.
39703 if(items.spr(j)->hit(w))
23795 {
23796 1859 item *theItem = ((item*)items.spr(j));
23797 1859 bool priced = theItem->PriceIndex >-1;
23798
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1852 times.
1859 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
23799
5/8
✓ Branch 0 taken 1859 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1859 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1495 times.
✓ Branch 5 taken 364 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 627 times.
2486 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
23800
4/6
✓ Branch 0 taken 991 times.
✓ Branch 1 taken 627 times.
✓ Branch 2 taken 991 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 991 times.
1859 || (((itemsbuf[pitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & ITEM_FLAG7)&&isKey))&& !priced)))
23801 {
23802
1/2
✓ Branch 0 taken 868 times.
✗ Branch 1 not taken.
2122 if(itemsbuf[theItem->id].collect_script)
23803 {
23804 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
23805 }
23806
23807 868 Hero.checkitems(j);
23808 868 }
23809 1859 }
23810 39703 }
23811 164816 }
23812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 261 times.
320921 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
23813 {
23814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 261 times.
261 for(int32_t j=0; j<items.Count(); j++)
23815 {
23816 if(items.spr(j)->hit(w))
23817 {
23818 item *theItem = ((item*)items.spr(j));
23819 bool priced = theItem->PriceIndex >-1;
23820 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
23821 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
23822 || (((itemsbuf[pitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & ITEM_FLAG7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
23823 {
23824 int32_t pickup = theItem->pickup;
23825 int32_t id2 = theItem->id;
23826 int32_t pstr = theItem->pstring;
23827 int32_t pstr_flags = theItem->pickup_string_flags;
23828
23829 std::vector<int32_t> &ev = FFCore.eventData;
23830 ev.clear();
23831 ev.push_back(id2*10000);
23832 ev.push_back(pickup*10000);
23833 ev.push_back(pstr*10000);
23834 ev.push_back(pstr_flags*10000);
23835 ev.push_back(0);
23836 ev.push_back(theItem->getUID());
23837 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
23838 ev.push_back(w->getUID());
23839
23840 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
23841 bool nullify = ev[4] != 0;
23842 if(nullify) continue;
23843 if(w->id == wBrang)
23844 {
23845 w->onhit(false);
23846 }
23847
23848 if(w->dragging==-1)
23849 {
23850 w->dead=1;
23851 theItem->clk2=256;
23852 w->dragging=j;
23853 theItem->is_dragged = true;
23854 }
23855 }
23856 }
23857 }
23858 261 }
23859 165077 }
23860 1187457 }
23861 1646597 }
23862 2805967 }
23863
23864 2806022 void dragging_item()
23865 {
23866
2/2
✓ Branch 0 taken 1673085 times.
✓ Branch 1 taken 2806022 times.
4479107 for(int32_t i=0; i<Lwpns.Count(); i++)
23867 {
23868 1673085 weapon *w = (weapon*)Lwpns.spr(i);
23869
23870
4/4
✓ Branch 0 taken 1509541 times.
✓ Branch 1 taken 163544 times.
✓ Branch 2 taken 1672825 times.
✓ Branch 3 taken 260 times.
1673085 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & ITEM_FLAG5)//ITEM_FLAG5 is a port for qr_Z3BRANG_HSHOT
23871 {
23872
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 260 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
260 if(w->dragging>=0 && w->dragging<items.Count())
23873 {
23874 item* dragItem = (item*)items.spr(w->dragging);
23875 dragItem->x=w->x;
23876 dragItem->y=w->y;
23877
23878 // Drag the Fairy enemy as well as the Fairy item
23879 int32_t id = dragItem->id;
23880
23881 if(itemsbuf[id].family ==itype_fairy && itemsbuf[id].misc3)
23882 {
23883 movefairynew2(w->x,w->y,*dragItem);
23884 }
23885 }
23886 260 }
23887 1673085 }
23888 2806022 }
23889
23890 15 int32_t more_carried_items()
23891 {
23892 15 int32_t hasmorecarries = 0;
23893
23894
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 15 times.
32 for(int32_t i=0; i<items.Count(); i++)
23895 {
23896
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 15 times.
17 if(((item*)items.spr(i))->pickup & ipENEMY)
23897 {
23898 15 hasmorecarries++;
23899 15 }
23900 17 }
23901
23902 15 return hasmorecarries;
23903 }
23904
23905 // messy code to do the enemy-carrying-the-item thing
23906 2806022 void roaming_item()
23907 {
23908
4/4
✓ Branch 0 taken 5342 times.
✓ Branch 1 taken 2800680 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 5327 times.
2806022 if(!(hasitem&(4|2)) || !loaded_enemies)
23909 2800695 return;
23910
23911 // All enemies already dead upon entering a room?
23912
1/2
✓ Branch 0 taken 5327 times.
✗ Branch 1 not taken.
5327 if(guys.Count()==0)
23913 {
23914 return;
23915 }
23916
23917 // Lost track of the carrier?
23918
4/6
✓ Branch 0 taken 5327 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5327 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5323 times.
✓ Branch 5 taken 4 times.
5327 if(guycarryingitem<0 || guycarryingitem>=guys.Count() ||
23919 5327 !((enemy*)guys.spr(guycarryingitem))->itemguy)
23920 {
23921 4 guycarryingitem=-1;
23922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 for(int32_t j=0; j<guys.Count(); j++)
23923 {
23924
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 4 times.
13 if(((enemy*)guys.spr(j))->itemguy)
23925 {
23926 4 guycarryingitem=j;
23927 4 break;
23928 }
23929 9 }
23930 4 }
23931
23932
2/2
✓ Branch 0 taken 5312 times.
✓ Branch 1 taken 15 times.
5327 if(hasitem&4)
23933 {
23934 15 guycarryingitem = -1;
23935
23936
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 15 times.
125 for(int32_t i=0; i<guys.Count(); i++)
23937 {
23938
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 15 times.
110 if(((enemy*)guys.spr(i))->itemguy)
23939 {
23940 15 guycarryingitem = i;
23941 15 }
23942 110 }
23943
23944
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(guycarryingitem == -1) //This happens when "default enemies" such as
23945 {
23946 return; //eSHOOTFBALL are alive but enemies from the list
23947 } //are not. Defer to HeroClass::checkspecial().
23948
23949 15 int32_t Item=tmpscr->item;
23950
23951 15 hasitem &= ~4;
23952
23953
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
15 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
23954 {
23955 28 additem(0,0,Item,ipENEMY+ipONETIME+ipBIGRANGE
23956
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 13 times.
15 + (((tmpscr->flags3&fHOLDITEM) || (itemsbuf[Item].family==itype_triforcepiece)) ? ipHOLDUP : 0)
23957 );
23958 15 hasitem |= 2;
23959 15 }
23960 else
23961 {
23962 return;
23963 }
23964 15 }
23965
23966
2/2
✓ Branch 0 taken 5832 times.
✓ Branch 1 taken 5327 times.
11159 for(int32_t i=0; i<items.Count(); i++)
23967 {
23968
2/2
✓ Branch 0 taken 505 times.
✓ Branch 1 taken 5327 times.
5832 if(((item*)items.spr(i))->pickup&ipENEMY)
23969 {
23970
2/2
✓ Branch 0 taken 2345 times.
✓ Branch 1 taken 2982 times.
5327 if(get_bit(quest_rules,qr_HIDECARRIEDITEMS))
23971 {
23972 2982 items.spr(i)->x = -128; // Awfully inelegant, innit?
23973 2982 items.spr(i)->y = -128;
23974 2982 }
23975
2/4
✓ Branch 0 taken 2345 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2345 times.
2345 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
23976 {
23977
1/2
✓ Branch 0 taken 2345 times.
✗ Branch 1 not taken.
2345 if (!get_bit(quest_rules, qr_BROKEN_ITEM_CARRYING))
23978 {
23979 if (get_bit(quest_rules, qr_ENEMY_DROPS_USE_HITOFFSETS))
23980 {
23981 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hxsz/2)-8;
23982 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hysz/2)-10;
23983 }
23984 else
23985 {
23986 if(guys.spr(guycarryingitem)->extend >= 3)
23987 {
23988 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
23989 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
23990 }
23991 else
23992 {
23993 items.spr(i)->x = guys.spr(guycarryingitem)->x;
23994 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
23995 }
23996 }
23997 items.spr(i)->z = guys.spr(guycarryingitem)->z;
23998 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
23999 }
24000 else
24001 {
24002 2345 items.spr(i)->x = guys.spr(guycarryingitem)->x;
24003 2345 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
24004 2345 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
24005 }
24006 2345 }
24007 5327 }
24008 5832 }
24009 2806022 }
24010
24011 bool enemy::IsBigAnim()
24012 {
24013 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
24014 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
24015 || anim == a4FRM8DIRB);
24016 }
24017
24018 const char *old_guy_string[OLDMAXGUYS] =
24019 {
24020 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
24021 // 020
24022 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
24023 // 025
24024 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
24025 // 030
24026 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
24027 // 035
24028 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
24029 // 040
24030 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
24031 // 045
24032 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
24033 // 050
24034 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
24035 // 055
24036 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
24037 // 060
24038 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
24039 // 065
24040 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
24041 // 070
24042 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
24043 // 075
24044 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
24045 // 080
24046 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
24047 // 085
24048 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
24049 // 090
24050 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
24051 // 095
24052 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
24053 // 100
24054 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
24055 // 105
24056 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
24057 // 110
24058 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
24059 // 115
24060 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
24061 // 120
24062 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
24063 // 125
24064 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
24065 // 130
24066 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
24067 // 135
24068 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
24069 // 140
24070 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
24071 // 145
24072 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
24073 // 150
24074 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
24075 // 155
24076 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
24077 // 160
24078 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
24079 // 165
24080 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
24081 // 170
24082 "Pols Voice (Magic) ", "Pols Voice (Whistle) ", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
24083 // 175
24084 "Grappler Bug (HP) ", "Grappler Bug (MP) "
24085 };
24086
24087 /*** end of guys.cc ***/
24088
24089